编辑代码

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
class Rec
{
    public:
        Rec(int x1,int y1):x(x1),y(y1){}
    public:
        int x;
    protected:
        int y;
    private:
        int z;
    public:
        ~Rec(){
            std::cout<<"The location part has been released"<<std::endl;
        }
    
};

class Pig:public Rec
{
public:
    Pig(int x1,int y1,int h1,int w1):Rec(x1,y1),h(h1),w(w1){}
    void printXYZ(){
        std::cout<<"x:"<<x<<",y:"<<y<<std::endl;
        std::cout<<"h:"<<h<<",w:"<<w<<std::endl;
   }
private:
    int h,w;
   ~Pig(){
       std::cout<<"The pig part has been released"<<std::endl;
   }
};

int main() {
    Pig p(23,32,232,34);
    p.printXYZ();

	return 0;
}