读书人

帮忙看下有什么有关问题

发布时间: 2012-04-04 16:38:51 作者: rapoo

帮忙看下有什么问题,在线等
#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

[解决办法]
class Cat
{
public:
Cat();
~Cat();
private:
int age;
};//分号不要忘了

\\这是第13行 //注释的斜杠是这么斜的/

读书人网 >C++

热点推荐