鱼C论坛

 找回密码
 立即注册
查看: 3724|回复: 2

C++继承的问题!

[复制链接]
发表于 2012-11-18 23:16:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 螃蟹009 于 2012-11-18 23:17 编辑

C++继承的问题,我使用的VC6.0,练习c++的继承的时候写的代码如下:
  1. # include <iostream>
  2. using namespace std;

  3. class Animal
  4. {
  5. public:
  6.         void eat ()
  7.         {
  8.                 cout << "Animal is eating!" << endl;
  9.         }
  10.         void sleep()
  11.         {
  12.                 cout << "Animal is sleeping!" << endl;
  13.         }
  14.         void breathe()
  15.         {
  16.                 cout <<"Animal is breathing!" <<endl;
  17.         }

  18. };
  19. class Fish() : public Animal
  20. {
  21.         
  22. };


  23. int main()
  24. {
  25.         Animal an;
  26.         an.eat();

  27.         return 0;
  28. }
复制代码
可是错误提示是
  1. C:\Users\Administrator.TBJIJSU3A122LQL\Desktop\test\1.cpp(21) : error C2059: syntax error : 'public'
复制代码
请问这是什么错误!!!!
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-11-18 23:23:34 | 显示全部楼层
21.class Fish()
改为
class Fish
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-11-18 23:31:05 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-16 10:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表