建立*.c结尾的文件
#include"iostream.h"
#include"time.h"
class TimeDate
{
public:
TimeDate(time_t t);
void Show();
private:
time_t systime;
}
TimeDate::TimeDate(time_t t)
{
systime=t;
}
void TimeDate::Show()
{
cout<<ctime(&systime);
}
void main()
{
time_t x;
x=time(NULL);
TimeDate ob(x);
ob.Show();
}
执行后
error C2061: syntax error : identifier 'TimeDate'
error C2059: syntax error : ';'
error C2449: found '{' at file scope (missing function header?)
error C2059: syntax error : '}'
error C2143: syntax error : missing '{' before ':'
error C2059: syntax error : ':'
error C2065: 'TimeDate' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'ob'
warning C4013: 'ob' undefined; assuming extern returning int
error C2224: left of '.Show' must have struct/union type
假如我加上#include"afxwin.h"错误为
error :  MFC requires C++ compilation (use a .cpp suffix)
Error executing cl.exe.
编译C++时,能不能不建立一个project啊。