帮忙看下有什么问题,在线等

diyemei 2007-04-03 02:10:47
#include <iostream>
using std::cout;

class Cat
{
public:
Cat();
~Cat();
private:
int age;
}

Cat::Cat() \\这是第13行
{
cout<<"Cons…called...\n";
age=2;
}

Cat::~Cat()
{
cout<<"Discons…called...\n";
}

int main()
{
cout<<"Cat Spot...\n";
Cat Spot;

cout<<"Cat *p=new Cat...\n";
Cat *p=new Cat;

cout<<"delete p...\n";
delete p;

cout<<"Exiting...\n";
return 0;
}

编译后有2个错误:
14 E:\Dev-Cpp\个人\10.1.cpp new types may not be defined in a return type
14 E:\Dev-Cpp\个人\10.1.cpp return type specification for constructor invalid
...全文
342 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
diyemei 2007-04-03
  • 打赏
  • 举报
回复
哦?QQ有的
369789339
加我说
hellox 2007-04-03
  • 打赏
  • 举报
回复
没有的!
==========================
晕,连QQ也没
diyemei 2007-04-03
  • 打赏
  • 举报
回复
没有的!我按了就没了
怎么才能有第二个啊要不你也 尝试下DEV-C++
hellox 2007-04-03
  • 打赏
  • 举报
回复
你有QQ么,我给你截个图,要不把QQ发到我的短消息里面吧..
hellox 2007-04-03
  • 打赏
  • 举报
回复
问题是我运行后只有1个
按任意键后窗口就没了
==========================
按任意键后窗口后还有1个的...
diyemei 2007-04-03
  • 打赏
  • 举报
回复
#include <iostream>
using std::cout;

class Cat
{
public:
Cat();
~Cat();
private:
int age;
};

Cat::Cat()
{
cout<<"Cons…called...\n";
age=2;
}

Cat::~Cat()
{
cout<<"Discons…called...\n";
}

int main()
{
cout<<"Cat Spot...\n";
Cat Spot;

cout<<"Cat *p=new Cat...\n";
Cat *p=new Cat;

cout<<"delete p...\n";
delete p;

cout<<"Exiting...\n";
system("pause");
return 0;
}

diyemei 2007-04-03
  • 打赏
  • 举报
回复
问题是我运行后只有1个
按任意键后窗口就没了
hellox 2007-04-03
  • 打赏
  • 举报
回复
Discons…called...是有2个的啊...
diyemei 2007-04-03
  • 打赏
  • 举报
回复
还是一样的啊
还是少一个Discons…called...
书上说是有2个的啊
菜鸟真痛苦啊
hellox 2007-04-03
  • 打赏
  • 举报
回复
那不知道了..那你选 调试->开始执行(不调试) 这个...
在VS2005下这个是ctrl+F5
diyemei 2007-04-03
  • 打赏
  • 举报
回复
dev-c++啊
hellox 2007-04-03
  • 打赏
  • 举报
回复
什么编译器啊,我的是VS2005
diyemei 2007-04-03
  • 打赏
  • 举报
回复
高手你尝试下我原来的代码啊
diyemei 2007-04-03
  • 打赏
  • 举报
回复
调试的时候按?
我一般都是直接按F9的,
我现在按了。出现一条红杠,不明白是什么意思
高手指教一下啊
hellox 2007-04-03
  • 打赏
  • 举报
回复
一开始调试的时候按啊...
你不会在
....
....
....
Exiting...
请按任意键继续...

的时候再按吧...
diyemei 2007-04-03
  • 打赏
  • 举报
回复
还是没用啊!!!
帮忙啊?
ctrl+F5在什么时候按啊
hellox 2007-04-03
  • 打赏
  • 举报
回复
按ctrl+F5试下
diyemei 2007-04-03
  • 打赏
  • 举报
回复
....
....
....
Exiting...
请按任意键继续...

然后随便按个

出现:

Discons…called...
请按任意键继续...


真的假的???我按了就没了啊
hellox 2007-04-03
  • 打赏
  • 举报
回复
在system("pause");再执行~Cat();??????

=========================
不好意思,是
在system("pause")执行以后再执行~Cat();
hellox 2007-04-03
  • 打赏
  • 举报
回复
....
....
....
Exiting...
请按任意键继续...

然后随便按个

出现:

Discons…called...
请按任意键继续...

加载更多回复(9)

33,319

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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