请各位高手给个指导
//head.h文件
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
class inputdata{
public:
inputdata(int,string,char,int,int);
~inputdata()
{cout<<"over!"<<endl;
getchar();}
void display();
private:
int id;
string name;
char sex;
int maths;
int chinese;
};
//head.cpp文件
#include "stdafx.h"
#include "head.h"
inputdata::inputdata(int a,string b,char c,int d, int e):id(a),name(b),sex(c),maths(d),chinese(e){}
void inputdata::display()
{
cout<<"name = "<<name<<endl;
cout<<"sum = "<<maths+chinese<<endl;
cout<<"sex = "<<sex<<endl<<endl;
}
//主函数
#include "stdafx.h"
#include "head.h"
int _tmain(int argc, _TCHAR* argv[])
{
inputdata student1;
student1.inputdata(5,"lhj",'f',99,89);
student1.display();
return 0;
}
编译提示:
错误 1 error C2512: 'inputdata' : no appropriate default constructor available archive.cpp 8
错误 2 error C2274: 'function-style cast' : illegal as right side of '.' operator archive.cpp 9
请教下!!! 随便要改进什么吗?
[此贴子已经被作者于2007-11-2 13:43:56编辑过]