Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ 8. (TCO 4) Consider the following class definitions. class bClass { public:

ID: 3850181 • Letter: C

Question

c++

8. (TCO 4) Consider the following class definitions.

class bClass
{
public:
     void setX(int a);
     //Postcondition: x = a;
     void print() const;

private:
     int x;
};

class dClass: public bClass
{
public:
     void setXY(int a, int b);
     //Postcondition: x = a; y = b;
     void print() const;

private:
     int y;
};

Which of the following correctly sets the values of x and y? (Points : 5)        void dClass::setXY(int a, int b)
{
     bClass::setX(a);
     y = b;
}
       void dClass::setXY(int a, int b)
{
     x = a;
     y = b;
}
       void dClass::setXY(int a, int b)
{
     x = bClass::setX(a);
     y = bClass::setY(b);
}
       void dClass::setXY(int a, int b)
{
     x = bClass.setX(a);
     b = y;
}

Explanation / Answer

1.
Answer:
class bClass(first program)
Explanation:
void setXY(int a, int b);

it is a function which takes 2 arguments

for a and b we can assign the values by creating object to child class that is dClass

dClass obj;
obj.setXY(2,3);

here above i pass 2 arguments that is 2,3 which can assign to the x and y.

2.member of a class can be defines as the the variables and the methods.
so in your given program we have 3 varibles that is
int day;
int month;
int year;

and 8 methods
void setDate(int, int, int);
void printDate() const;
void setDay(int);
void setMonth(int);
void setYear(int);
int getDay();
int getDay();
int getDay();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote