C++刚刚看到类 照着书里的程序写了一遍 不知道怎么有错误。
求大虾们解释一下。 那里出错了。//Studenr61_1.h
#include<iostream.h>
#include<string.h>
class student
{
private:
unsigned int code;
string name;
public:
void SetCode(unsigned int code)
{
this->code=code;
}
int GetCode()
{
return code;
}
void SetName(string name)
{
this->name=name;
}
string GetName()
{
return name;
}
void shoe();
};
void Students::show()
{
cout<<"编号:"<<code<<"\t"<<"姓名"<<name<<"\t";
}
--------------------Configuration: jj - Win32 Debug--------------------
Compiling...
jj.cpp
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(9) : error C2146: syntax error : missing ';' before identifier 'name'
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(9) : error C2501: 'string' : missing storage-class or type specifiers
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(9) : error C2501: 'name' : missing storage-class or type specifiers
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(11) : error C2059: syntax error : 'constant'
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(19) : error C2061: syntax error : identifier 'string'
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(23) : error C2146: syntax error : missing ';' before identifier 'GetName'
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(23) : error C2501: 'string' : missing storage-class or type specifiers
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(26) : warning C4183: 'GetName': member function definition looks like a ctor, but name does not match enclosing class
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(29) : error C2653: 'Students' : is not a class or namespace name
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(31) : error C2065: 'code' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\编程文件存档\jj.cpp(31) : error C2065: 'name' : undeclared identifier
执行 cl.exe 时出错.
jj.obj - 1 error(s), 0 warning(s)
急。。。。