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

请各位老师指导,小弟我在便c++时,出现的有关问题

2012-02-04 
请各位老师指导,我在便c++时,出现的问题!#includeiostreamusingnamespacestdclassCat{public:Cat(intna

请各位老师指导,我在便c++时,出现的问题!
#include   <iostream>

using   namespace   std;
class   Cat
{
public:
Cat(int   names,   int   Age);
Cat(Cat   &c);
static   void   GetHowMany()   {   cout < < "HowManyCats:   " < <HowManyCats < <endl;   }
~Cat(){}
char   *GetName();
int   GetAge();
private:
int   name;
int   age;
static   int   HowManyCats;
}
  Cat::Cat(int   names,   int   Age)
{
name=names;
age=Age;
HowManyCats++;
}
Cat::Cat(   Cat   &c)
{
name=c.name;
age=c.age;
HowManyCats++;
}

int   Cat::HowManyCats=0;
int   main()
{

Cat   A(01,5);
cout < < "Cat   A:   " < <A.GetName() < < ",   Age: " < <A.GetAge();
A.GetHowMany();
Cat   B(A);
cout < < "Cat   B:   " < <B.GetName() < < ",   Age: " < <B.GetAge();
Cat::GetHowMany();
return   0;
}
--------------------Configuration:   ex5_7   -   Win32   Debug--------------------
Compiling...
ex5_7.cpp
d:\ex5_7.cpp(19)   :   error   C2533:   'Cat::Cat '   :   constructors   not   allowed   a   return   type
d:\ex5_7.cpp(35)   :   error   C2264:   'Cat::Cat '   :   error   in   function   definition   or   declaration;   function   not   called
执行   cl.exe   时出错.

ex5_7.obj   -   1   error(s),   0   warning(s)
谢谢

[解决办法]
private:
int name;
int age;
static int HowManyCats;
};
少了个分号
[解决办法]
你类最后少了一个分号

class Cat
{
}; //here
[解决办法]
GetName函数没有实现
会报链接错误
[解决办法]
;又是分号的错!!!

热点排行