Answer to Question #239537 in C++ for being

Question #239537

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;}


1
Expert's answer
2021-09-25T05:20:26-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS