标题:继承与派生类
取消只看楼主
zcdjt
Rank: 3Rank: 3
等 级:论坛游侠
威 望:4
帖 子:99
专家分:181
注 册:2014-9-9
结帖率:85.71%
已结贴  问题点数:5 回复次数:0 
继承与派生类
#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



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




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

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