我收到错误extra qualification ‘student::’ on member ‘student’ [-fpermissive]
。
而且为什么name::name
这样的语法在构造函数中使用?错误“额外资格”学生::'在成员'学生'[-fpermissive]“
#include<iostream>
#include<string.h>
using namespace std;
class student
{
private:
int id;
char name[30];
public:
/* void read()
{
cout<<"enter id"<<endl;
cin>>id;
cout<<"enter name"<<endl;
cin>>name;
}*/
void show()
{
cout<<id<<name<<endl;
}
student::student()
{
id=0;
strcpy(name,"undefine");
}
};
main()
{
student s1;
// s1.read();
cout<<"showing data of s1"<<endl;
s1.show();
// s2.read();
//cout<<"showing data of s2"<<endl;
//s2.show();
}
什么是这种资格的使用或当我们必须使用它 – wizneel 2012-07-27 17:40:45
@ user1306088:资格'学生::'只有在您定义函数以外的类时才需要,通常在.cpp文件中。 – Nawaz 2012-07-27 17:41:10