#include <iostream>
using namespace std;
class A
{
protected:
int x,y,z;
public:
A(int a) : x(a),y(a*a),z(a*a*a) {cout<<"Конструктор А "<<this<<endl;}
virtual ~A() {cout<<"Деструктор А "<<this<<endl;}
virtual void func_1(A *) const =0 ;
virtual void func_2() const =0 ;
int get_x() const {return x;}
int get_y() const {return y;}
int get_z() const {return z;}
};
class B : public A
{
public:
B(int a) : A(a) {cout<<"Конструктор B "<<this<<endl;}
~B() {cout<<"Деструктор B "<<this<<endl;}
void func_1(A *b) const
{
cout<<"Данные класса C: ";
cout<<"x = "<<b->get_x();
cout<<" y = "<<b->get_y();
cout<<" z = "<<b->get_z()<<endl;
b->func_2();
}
void func_2() const{cout<<"Класс B x = "<<x
<<" y = "<<y<<" z = "<<z<<endl;}
};
class C : public A
{
public:
C(int a) : A(a) {cout<<"Конструктор C "<<this<<endl;}
~C() {cout<<"Деструктор C "<<this<<endl;}
void func_1(A *c) const
{
cout<<"Данные класса B: ";
cout<<"x = "<<c->get_x();
cout<<" y = "<<c->get_y();
cout<<" z = "<<c->get_z()<<endl;
c->func_2();
}
void func_2() const{cout<<"Класс C x = "<<x
<<" y = "<<y<<" z = "<<z<<endl;}
};
int main()
{
A *c = new C(56);
A *b = new B(45);
c->func_1(b);
b->func_1(c);
cout<<"***************************"<<endl;
return 0;
}