建立*.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啊。
#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啊。
解决方案 »
- OllyDbg打API断点失败,求指点!!!
- 请问我想实现这样的一个效果,请问谁有好一点的算法 谢谢
- 急问:关于创建ADO全局对象的问题;在线等
- ActiveX莫名其妙不能注册了,这是什么原因啊。
- 请教高手,关于HOOK的问题
- 文件路径过长会导致CFileFind::FindFile报错?
- 大家帮忙看看这段代码有什么问题吗,为什么CPU占用率这么高?
- [HOOK]键盘HOOK问
- 数据库中的字段名为英文,需在程序中显示字段名为中文!
- 如果把edit设成value,int,怎么才能允许用户不填任何数据呢
- CHttpFile::SendRequest无法返回,求助!!!
- 在VC.NET中ATL编程,如何使用httpfile类
{
};