注册 登录
编程论坛 C++教室

继承与派生类

zcdjt 发布于 2014-09-14 19:09, 409 次点击
#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;
}
3 回复
#2
七夜之华2014-09-14 20:50
扑通,要沉啊。。。
#3
ditg2014-09-15 16:30
1. int x, int y
2. #include <cstdlib>
#4
阿周20142014-09-19 23:48
你这是想问什么呢?
1