|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include<iostream>
- #include<string>
- using namespace std;
- class Student
- {
- public:
- Student(int n,string nam,char s)
- {
- num = n;
- name = nam;
- sex = s;
- cout << "Constructor called." << endl;
- }
- ~Student()
- {
- cout << "Constructor called." << endl;
- }
- void display()
- {
- cout << "num:" << num << endl;
- cout << "name:" << name << endl;
- cout << "sex:" << sex << endl << endl;
- }
- private:
- int num;
- char name[10];
- char sex;
- };
- int main()
- {
- Student stu1(10086,"Zhang_wu_ji",'M');
- stu1.display();
- Student stu2(10000,"Zhao_ming",'F');
- stu2.display();
- return 0;
- }
复制代码 最后提示“error C2440: “=”: 无法从“std::string”转换为“char [10]”,这需要怎么修改才行
” |
|