注册 登录
编程论坛 新人交流区

[讨论]一个程序为什么出现了这么多错误

风声边界 发布于 2007-11-02 14:06, 285 次点击


#include <iostream.h>
#include <windows.h>
struct MyClass
{
public:
static int i;
};
//int MyClass::i;
void main()
{
struct MyClass cls1;
struct MyClass cls2;
cls1.i=1;
cout<<"cls1.i="<<cls1.i<<" cls2.i="<<cls2.i<<endl;
cls2.i=2;
cout<<"cls1.i="<<cls1.i<<" cls2.i="<<cls2.i<<endl;
}

C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(5) : error C2061: syntax error : identifier 'public'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(7) : error C2059: syntax error : '}'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(11) : error C2079: 'cls1' uses undefined struct 'MyClass'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(12) : error C2079: 'cls2' uses undefined struct 'MyClass'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(13) : error C2224: left of '.i' must have struct/union type
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(14) : error C2065: 'cout' : undeclared identifier
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(14) : error C2297: '<<' : illegal, right operand has type 'char [8]'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(14) : error C2224: left of '.i' must have struct/union type
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(14) : error C2224: left of '.i' must have struct/union type
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(14) : error C2065: 'endl' : undeclared identifier
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(15) : error C2224: left of '.i' must have struct/union type
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(16) : error C2297: '<<' : illegal, right operand has type 'char [8]'
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(16) : error C2224: left of '.i' must have struct/union type
C:\Documents and Settings\aaa\桌面\c1\eg1\eg2.c(16) : error C2224: left of '.i' must have struct/union type
Error executing cl.exe.

eg2.exe - 14 error(s), 0 warning(s)

0 回复
1