首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

帮忙看下有什么有关问题

2012-04-04 
帮忙看下有什么问题,在线等#includeiostreamusingstd::coutclassCat{public:Cat()~Cat()private:inta

帮忙看下有什么问题,在线等
#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行 //注释的斜杠是这么斜的/

热点排行