#include <iostream>
static int n=0;
class CType
{
public:
CType()
{
m_n=n++;
int m_n;
}
};
CType d;
void fs()
{
static CType s;
cout<<"s."<<s.m_n<<endl;
}
void fa()
{
CType a;
cout<<"a."<<a.m_n<<endl;
}
void main()
{
fs();
fs();
fa();
fa();
}
--------------------Configuration: diaoyong2 - Win32 Debug--------------------
Compiling...
diaoyong2.cpp
e:\vc++\add\diaoyong2\diaoyong2.cpp(8) : error C2065: 'm_n' : undeclared identifier
e:\vc++\add\diaoyong2\diaoyong2.cpp(17) : error C2065: 'cout' : undeclared identifier
e:\vc++\add\diaoyong2\diaoyong2.cpp(17) : error C2297: '<<' : illegal, right operand has type 'char [3]'
e:\vc++\add\diaoyong2\diaoyong2.cpp(17) : error C2039: 'm_n' : is not a member of 'CType'
e:\vc++\add\diaoyong2\diaoyong2.cpp(4) : see declaration of 'CType'
e:\vc++\add\diaoyong2\diaoyong2.cpp(17) : error C2065: 'endl' : undeclared identifier
e:\vc++\add\diaoyong2\diaoyong2.cpp(23) : error C2297: '<<' : illegal, right operand has type 'char [3]'
e:\vc++\add\diaoyong2\diaoyong2.cpp(23) : error C2039: 'm_n' : is not a member of 'CType'
e:\vc++\add\diaoyong2\diaoyong2.cpp(4) : see declaration of 'CType'
执行 cl.exe 时出错.
diaoyong2.exe - 1 error(s), 0 warning(s)