| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 597 人关注过本帖
标题:请各位大侠帮忙解释并调试,看错误在哪里?
只看楼主 加入收藏
海之约echo
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-11-27
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
请各位大侠帮忙解释并调试,看错误在哪里?
// wo.cpp : Defines the entry point for the console application.一个父亲,黄皮肤,黑眼睛,可以说中国话,有音乐天赋,一个母亲
//,白皮肤,蓝眼睛,可以说中国话和英语,有计算天赋,他们的儿子,黄皮肤,黑眼睛,可以说中国话和英语
//,有音乐天赋,计算天赋和体育天赋,一个男医生,黄皮肤,蓝眼睛,可以说中国话,有文学天赋,他将位以上父母和他们的儿子检查身体。
//。编程实现他们的继承关系和展示其各自的天赋
//.编程实现医生为该父母和男孩检查成为函数。
//
 
#include <iostream.h>
#include <string.h>
class human
{
   protected:
      char name[10];
       char skin[10];
       char eyes[10];
       char language[10];
       char ta[10];
   public:
       human(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
virtual       void speak()
       {cout<<"humam 可以讲"<<language<<endl;}
       void talante()
       {cout<<"天赋"<<ta<<endl;}
       char Getname()
       {cout<<"name ="<<name<<endl;}
};
class father:virtual public human
{
public:
    father(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
         virtual void speak()
       {cout<<" father 可以讲"<<language<<endl;}
        void talante()
       {cout<<"天赋"<<ta<<endl;}
};
class mother:virtual public human
{
public:
       mother(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
         void speak()
       {cout<<" mother 可以讲"<<language<<endl;}
         void talante()
       {cout<<"mother 天赋"<<ta<<endl;}
};
class  doctor:public human
{public:
     doctor(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
       virtual  void speak()
       {cout<<"  doctor 可以讲"<<language<<endl;}
        void talante()
       {cout<<" doctor 天赋"<<ta<<endl;}
       void  check()
       {cout<<"check name="<<doctor::Getname()<<endl;}
};
class son:public father,public mother
{public:
     son(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
       void speak()
       {cout<<"  son 可以讲"<<language<<endl;}
        void talante()
       {cout<<" son 天赋"<<ta<<endl;}
};
void main()
{father  1("yi","huang","bai","han","yinyue");
mother 2("er","bai","lan","hanying","ji");
doctor 3("san","huang","hei","han","wen");
son 4("si","huang","hei","hanying","yinjiti");
1. speak();
1.talante();
2.speak();
2.talante()
 4.speak();
  4. talante();
}

搜索更多相关主题的帖子: 调试 解释 
2010-11-27 17:34
shafeilong
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:236
专家分:1434
注 册:2009-3-21
收藏
得分:10 
拜托  数字能当做变量么。。。。把所有的1 2 3 4 改掉  改成a1  a2  a3  a4  顺便2.talante()
  后面添个分号
2010-11-27 17:58
VenusNefu
Rank: 2
等 级:论坛游民
帖 子:14
专家分:11
注 册:2010-11-24
收藏
得分:10 
回复 楼主 海之约echo
程序代码:
#include <iostream>
#include <string.h>
using namespace std;
class human
{
   protected:
      char name[10];
       char skin[10];
       char eyes[10];
       char language[10];
       char ta[10];
   public:
       human(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
virtual       void speak()
       {cout<<"humam 可以讲"<<language<<endl;}
       void talante()
       {cout<<"天赋"<<ta<<endl;}
       char Getname()
       {cout<<"name ="<<name<<endl;}
};
class father:virtual public human
{
public:
    father(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
         virtual void speak()
       {cout<<" father 可以讲"<<language<<endl;}
        void talante()
       {cout<<"天赋"<<ta<<endl;}
};
class mother:virtual public human
{ 
public:
       mother(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
         void speak()
       {cout<<" mother 可以讲"<<language<<endl;}
         void talante()
       {cout<<"mother 天赋"<<ta<<endl;}
};
class  doctor:public human
{public:
     doctor(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
       virtual  void speak()
       {cout<<"  doctor 可以讲"<<language<<endl;}
        void talante()
       {cout<<" doctor 天赋"<<ta<<endl;}
       void  check()
       {cout<<"check name="<<doctor::Getname()<<endl;}
};
class son:public father,public mother
{public:
     son(char *na="unknown",char *sk="unknown",char *ey="unknown",char *la="unknown",char *t="unknown")
       {    strcpy(name,na);
            strcpy(skin,sk);
            strcpy(eyes,ey);
            strcpy(language,la);
            strcpy(ta,t);
       }
       void speak()
       {cout<<"  son 可以讲"<<language<<endl;}
        void talante()
       {cout<<" son 天赋"<<ta<<endl;}
};
void main()
{father  a1("yi","huang","bai","han","yinyue");
mother a2("er","bai","lan","hanying","ji");
doctor a3("san","huang","hei","han","wen");
son a4("si","huang","hei","hanying","yinjiti");
a1. speak();
a1.talante();
a2.speak();
a2.talante();
a4.speak();
a4. talante();
}
2010-11-29 14:16
快速回复:请各位大侠帮忙解释并调试,看错误在哪里?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044823 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved