面向对象编程第四版王育坚
时间: 2023-10-27 07:07:48 浏览: 80
《面向对象编程第四版》是一本由王育坚编写的计算机编程教材,介绍了面向对象编程的基本概念、原则、方法和技术。本书从面向对象的思想出发,系统讲解了面向对象的程序设计与实现,围绕类、对象、继承、多态等概念展开阐述。
本书主要内容分为两大部分:第一部分是面向对象的基础知识,包括面向对象的概念、特点、原则等;第二部分是Java语言的面向对象编程,包括类、对象、继承、多态、接口、异常处理等内容。此外,本书还介绍了面向对象的设计模式、UML建模、Java的IO和网络编程等知识,全面深入地讲解了面向对象编程的理论和实践。
本书适合计算机专业的学生、程序员和软件工程师阅读,也适合对面向对象编程感兴趣的读者学习。本书的特点在于深入浅出,理论结合实践,让读者可以循序渐进地学习面向对象编程的知识。
相关问题
vc 面向对象程序设计 王育坚
VC 面向对象程序设计是一门关于面向对象编程的课程,由王育坚教授执教。作为一门计算机科学的基础课程,VC 面向对象程序设计旨在帮助学生深入了解面向对象编程的概念和原理,并掌握使用 Visual C++ 进行面向对象程序设计的技能。
在这门课程中,学生将学习如何使用 Visual C++ 编程语言来进行面向对象的程序设计。他们将学习如何创建类和对象,并掌握封装、继承和多态等面向对象编程的重要概念。此外,学生还将学习如何使用 Visual Studio 这一集成开发环境来进行程序的设计和调试,从而提高他们的编程能力和解决问题的能力。
通过VC 面向对象程序设计,学生不仅可以掌握面向对象编程的理论知识,还可以通过实际的项目实践来巩固所学的知识,并将其运用到实际的软件开发中。此外,王育坚教授作为经验丰富的专业人士,将会为学生提供丰富的案例和实用的经验,帮助他们更好地理解和应用面向对象程序设计的知识。
总之,VC 面向对象程序设计是一门对于计算机科学专业学生非常重要的课程,通过学习这门课程,学生可以获得扎实的面向对象程序设计基础,并为将来的软件开发工作做好准备。
设计书类Book,成员函数包括作者(char author[40]),书名(char title[40]),价格(double price)。根据给定的main函数设计必要的成员函数。 main函数已给定,提交时只需要提交main函数外的代码部分。 #include<iostream> #include<cstring> #include<iomanip> using namespace std; //你提交的代码在这里 int main() { cout<<fixed<<setprecision(2); Book b1; cout<<"Show object b1:"; cout<<b1.GetTitle()<<","<<b1.GetAuthor()<<","<<b1.GetPrice()<<endl; char title[40],author[40]; double price; cin>>title>>author>>price; Book b2(title,author,price); cout<<"Show object b2:"; cout<<b2.GetTitle()<<","<<b2.GetAuthor()<<","<<b2.GetPrice()<<endl; cin>>title>>author>>price; cout<<"Reset and Show object b1:"; b1.Set(title,author,price); b1.Show(); cout<<"Reset and Show object b2:"; b2.Set(); b2.Show(); return 0; } 输入 2行,每行3个数据,分别代表一本书的书名、作者以及价格。 输出 按照样例输出格式输出。 输入样例 1 C++程序设计 郑莉 45.12 c++程序设计基础 王育坚 68.5 输出样例 1 Show object b1:NULL,NONE,0.00 Show object b2:C++程序设计,郑莉,45.12 Reset and Show object b1:c++程序设计基础,王育坚,68.50 Reset and Show object b2:高等数学(第七版)上册,同济大学数学系,37.70
```
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
class Book {
private:
char author[40];
char title[40];
double price;
public:
Book() {
strcpy(this->author, "NONE");
strcpy(this->title, "NULL");
this->price = 0.00;
}
Book(char title[], char author[], double price) {
strcpy(this->author, author);
strcpy(this->title, title);
this->price = price;
}
char* GetAuthor() { return this->author; }
char* GetTitle() { return this->title; }
double GetPrice() { return this->price; }
void Set(char title[], char author[], double price) {
strcpy(this->author, author);
strcpy(this->title, title);
this->price = price;
}
void Set() {
char title[40], author[40];
double price;
cin >> title >> author >> price;
Set(title, author, price);
}
void Show() {
cout << this->title << "," << this->author << "," << fixed << setprecision(2) << this->price << endl;
}
};
int main() {
cout << fixed << setprecision(2);
Book b1;
cout << "Show object b1:";
cout << b1.GetTitle() << "," << b1.GetAuthor() << "," << b1.GetPrice() << endl;
char title[40], author[40];
double price;
cin >> title >> author >> price;
Book b2(title, author, price);
cout << "Show object b2:";
cout << b2.GetTitle() << "," << b2.GetAuthor() << "," << b2.GetPrice() << endl;
cin >> title >> author >> price;
cout << "Reset and Show object b1:";
b1.Set(title, author, price);
b1.Show();
cout << "Reset and Show object b2:";
b2.Set();
b2.Show();
return 0;
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)