找不到的错误,请指教!

liutjedu 2003-11-01 09:35:21
class TDate1
{
public:
TDate1(int y,int m,int d)
~TDate1();
void Print();
private:
int year,month,day;
};
TDate1::TDate1(int y,int m,int d)
{
year=y;month=m;day=d;
cout<<"Constructor Called. \n";
}
TDate1::~TDate1()
{
cout<<"destructor called. \n";
}
void TDate1::Print()
{cout<<year<<"."<<month<<"."<<day<<endl;
}
居然这么多的错误,哎,郁闷中!请教大家:
Info :Compiling G:\C++\TDate.cpp
Error: TDate.cpp(5,5):Declaration terminated incorrectly
Error: TDate.cpp(13,10):Undefined symbol 'cout'
Error: TDate.cpp(16,2):'TDate1::~TDate1()' is not a member of 'TDate1'
Error: TDate.cpp(17,29):Illegal character '\' (0x5c)
Error: TDate.cpp(20,8):Undefined symbol 'cout'
Error: TDate.cpp(20,41):Undefined symbol 'endl'

...全文
19 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aliker 2003-11-02
  • 打赏
  • 举报
回复
Error: TDate.cpp(5,5):Declaration terminated incorrectly
TDate1(int y,int m,int d);少了个分号
Error: TDate.cpp(13,10):Undefined symbol 'cout'
加上头文件#include "iostream.h"
Error: TDate.cpp(16,2):'TDate1::~TDate1()' is not a member of 'TDate1'
TDate1(int y,int m,int d);少了个分号
Error: TDate.cpp(17,29):Illegal character '\' (0x5c)
程序里有全角空格,
Error: TDate.cpp(20,8):Undefined symbol 'cout'
加上头文件#include "iostream.h"
Error: TDate.cpp(20,41):Undefined symbol 'endl'
加上头文件#include "iostream.h"
正确的代码
#include "iostream.h"
class TDate1
{
public:
TDate1(int y,int m,int d);
~TDate1();
void Print();
private:
int year,month,day;
};
TDate1::TDate1(int y,int m,int d)
{
year=y;month=m;day=d;
cout<<"Constructor Called. \n";
}
TDate1::~TDate1()
{
cout<<"destructor called. \n";
}
void TDate1::Print()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
freshman2003 2003-11-01
  • 打赏
  • 举报
回复
1、include "stdio.h"。
2、对于Illegal character '\' (0x5c)这个错误,很可能是你的程序中有全角空格。
95533 2003-11-01
  • 打赏
  • 举报
回复
晕~
TDate1(int y,int m,int d)

少了个 ; 号

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧