C++&QT 作业5

C++&QT 作业5_第1张图片

#include 
#define PI 3
using namespace std;
class Shape
{
protected:
    int zc;
    int mj;
public:
    Shape(){}
    Shape(int z,int m):zc(z),mj(z){}
    ~Shape(){}

    Shape(const Shape &other):zc(other.zc),mj(other.mj)
    {
        cout<<"拷贝构造函数"<zc = other.zc;
        this->mj = other.mj;
        cout<<"拷贝赋值函数"<bj= other.bj;
        }
        cout<<"拷贝赋值函数"<zc=2*PI*bj;
        return this->zc;
    }
    int get_mj()
    {
        this->mj=PI*bj*bj;
        return this->mj;
    }
};
class Rect:public Circle
{
private:
    int cd;
    int kd;
public:
    Rect (){}
    Rect (int c,int k):cd(c),kd(k){}
    Rect & operator=(const Rect &other)
     {
         if(this != &other)
         {
             this->cd = other.cd;
             this->kd = other.kd;
         }
         cout<<"拷贝赋值函数"<zc = 2*(cd+kd);
         return this->zc;
     }
     int get_mj()//获取面积函数
     {
         this->mj = cd*kd;
         return this->mj;
     }
};
int main()
{
    Circle c(2);
    cout<<"c周长="<

你可能感兴趣的:(c++,qt,开发语言)