|
//一个带类的c++
#include <iostream>
using namespace std;
class Student
{private:
int num;
int score;
public:
void setdata()
{cin >>num: //!!我这里错了!!
cin >>score;
}
void display()
{cout <<"num=" <<num <<endl;
cout <<"score=" <<score <<endl;
};
};
Student stud1,stud2;
int main()
{stud1.setdata();
stud2.setdata();
stud1.display();
stud2.display();
return 0;
}
编译不过:
[wrsg@redapple programme]$ g++ -o classc classc.C
classc.C: In member function ‘int Student::setdata()’:
classc.C:11: 错误:expected `;' before ‘:’ token
[wrsg@redapple programme]$
请弟兄们给我看看这个是什么问题
P.S. 找出问题了.原来我把分号打成冒号了.是我不够仔细. |
|