Write the parameterized constructor for all the classes in the hierarchy.
class A
{ int a;}
Class B:public virtual A
{int b;}
Class C:public virtual A
{int c; }
Class D:public b,public C
{int d;}
#include <iostream>
using namespace std;
class Point
{
private:
int A, B;
public:
Point(int x1, int y1)
{
A = x1;
B = y1;
}
int getC()
{
return A;
}
int getD()
{
return B;
}
};
int main()
{
Point p1(10, 15);
cout << "p1.A = " << p1.getC() << ", p1.B = " << p1.getD();
return 0;
}
Comments
Leave a comment