我的简单程序编译不过,请高手指教
我在空工程(蔡泽华)里面建立3个文件,编译出现错误,如下:
主文件40224.cpp:
#include<iostream.h>
#include<string.h>
#include "224.h"
void main()
{
MyClass MC;
MC.MyClass("蔡泽华","071240224");
MC.Print();
}
头文件224.h:
#include<iostream.h>
#include<string.h>
class MyClass
{
private:
char Name[10],No[10];
public:
MyClass()
{
strcpy(Name,"default");
strcpy(No,"999999");
}
MyClass(char *name,char *no);
void Print();
}
实现头文件里面 类的函数224.cpp
#include<iostream.h>
#include<string.h>
#include"224.h"
MyClass::MyClass(char *name,char *no)
{
strcpy(Name,name);
strcpy(No,no);
}
MyClass::Print()
{
cout<<"我的名字是"<<Name<<endl;
cout<<"我的学号是"<<No<<endl;
}
编译出现如下错误:
--------------------Configuration: 蔡泽华 - Win32 Debug--------------------
Compiling...
224.cpp
c:\documents and settings\administrator\桌面\面向对象程序设计\071240224\蔡泽华\224.cpp(4) : error C2143: syntax error : missing ';' before 'PCH creation point'
40224.cpp
c:\documents and settings\administrator\桌面\面向对象程序设计\071240224\蔡泽华\40224.cpp(3) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:\documents and settings\administrator\桌面\面向对象程序设计\071240224\蔡泽华\40224.cpp(6) : error C2274: 'function-style cast' : illegal as right side of '.' operator
执行 cl.exe 时出错.
蔡泽华.exe - 1 error(s), 0 warning(s)