c++ 问题求解 error C2062: type 'void' 怎么回事呢??急
#include<iostream>usingnamespacestd;classstudent{private:intnum;intscore;pubilc:voids...
#include <iostream>
using namespace std;
class student
{
private:
int num;
int score;
pubilc:
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;
}
Compiling...
firstclass.cpp
D:\microsoft visual c++\MSDev98\MyProjects\firstproject\firstclass.cpp(12) : error C2062: type 'void' unexpected
D:\microsoft visual c++\MSDev98\MyProjects\firstproject\firstclass.cpp(13) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body 展开
using namespace std;
class student
{
private:
int num;
int score;
pubilc:
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;
}
Compiling...
firstclass.cpp
D:\microsoft visual c++\MSDev98\MyProjects\firstproject\firstclass.cpp(12) : error C2062: type 'void' unexpected
D:\microsoft visual c++\MSDev98\MyProjects\firstproject\firstclass.cpp(13) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body 展开
1个回答
2015-05-03
展开全部
pubilc: 写错了 public
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询