我在成员’学生'[-fpermissive]上获得了更多的资格“student ::”的错误.
还有为什么name :: name这样的语法在构造函数中使用?
还有为什么name :: name这样的语法在构造函数中使用?
#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(); }