📄 v-overload.cpp
字号:
// V-Overload.cpp
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
//---- 宣告类别 Shape --------
class Shape
{
private:
int i;
public:
Shape(): i(7){}
~Shape(){}
virtual void Rotate() {cout<<"将图回转 \n";}
virtual void Rotate(int N)
{cout<<"将图回转 "<< N << " 单位\n";}
virtual void Erase() {cout<<"将图清除\n";}
};
//---- 宣告类别 Circle--------
class Circle : public Shape
{
private:
int r;
public:
Circle(): r(5) {}
Circle(int N): r(N) {}
~Circle() {}
void Rotate() {cout<<"将圆形回转\n";}
void Erase() {cout<<"把圆形清除 \n";}
};
//---- 宣告类别 Cylinder--------
class Cylinder : public Circle
{
private:
int r, h;
public:
Cylinder(): r(5), h(1) {}
Cylinder(int M, int N): r(M), h(N) {}
~Cylinder() {}
void Rotate(){cout<<"将圆柱形回转\n";}
void Erase() {cout<<"把圆柱形清除 \n";}
};
// ----主程式---------------------------
main()
{
Circle C1;
Cylinder CyL;
Shape *pS = &C1;
Shape &S1 = CyL;
cout << "“pS->Rotate()” : ";
pS->Rotate();
cout << "“pS->Rotate(2)”: ";
pS->Rotate(2);
cout << "“ S1.Rotate()” : ";
S1.Rotate();
cout << "“ S1.Rotate(4)”: ";
S1.Rotate(4);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -