标题:继承与派生类
只看楼主
zcdjt
Rank: 3Rank: 3
等 级:论坛游侠
威 望:4
帖 子:99
专家分:181
注 册:2014-9-9
结帖率:85.71%
已结贴  问题点数:5 回复次数:3 
继承与派生类
#include<iostream>
using namespace std;
class Point
{
      public:
          void point(int x=0,int y=0,char hue[8])
             {
               strcpy(Hue,hue);         
               a=x;
               b=y;
             }
      protected:
                int a,b;
                char Hue[8];
};
class Colour:public Point
{
      public:
       void colour(int x,int y,char hue[8])
       {
            x=a;
            y=b;
            strcpy(Hue,hue);
            }
            void xianshi()
            {
              int x,y;
              char k[8];
              cout<<"请输入横坐标:";
              cin>>x;
              cout<<"横纵坐标为"<<x<<endl;
              cout<<"请输入纵坐标:";
              cin>>y;
              cout<<"纵坐标是"<<y<<endl;
              cout<<"请输入你想要显示的颜色:";
              cin>>k;
               cout<<"颜色为:"<<k<<endl;
              }                                         
             void show()
             {                                 
              xianshi();            
              
             }
};
class Move:public Point
{
      public:
            void  move(int x,int y)
            {
                  x=a;
                  y=b;
            }
            void M()
            {
                 int m,n;
                 cout<<"请输入横坐标:";
                 cin>>m;
                 cout<<"请输入纵坐标:";
                 cin>>n;
                 m+=m;
                 cout<<"扩大后的横坐标是:"<<m<<endl;
                 n+=n;
                 cout<<"扩大后的纵坐标是:"<<n<<endl;
            }
      void show()
      {
         M();                             
      }
};
int main()
{
    Colour c;
    c.show();
    Move dd;
    dd.show();
    system("pause");
    return 0;
}
搜索更多相关主题的帖子: include public 
2014-09-14 19:09
七夜之华
Rank: 3Rank: 3
来 自:China
等 级:论坛游侠
威 望:5
帖 子:82
专家分:103
注 册:2014-9-7
得分:2 
扑通,要沉啊。。。

#############################################
##########################################
因为不懂、才要学习、只有学习、才有进步。
2014-09-14 20:50
ditg
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:16
帖 子:852
专家分:1937
注 册:2014-4-10
得分:2 
1. int x, int y
2. #include <cstdlib>

梦想拥有一台龙芯3A-4000
2014-09-15 16:30
阿周2014
Rank: 1
等 级:新手上路
帖 子:1
专家分:2
注 册:2014-4-18
得分:2 
你这是想问什么呢?
2014-09-19 23:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-436086-1-1.html




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

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