继承与派生类
#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;
}