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

Given the following class, which function is used to initialize the data members

ID: 3823088 • Letter: G

Question

Given the following class, which function is used to initialize the data members when an instance of the object is declared? (C++)

class myClass
{
   private:
int x, y;

   public:
myClass();
void setValues(int _x, int _y) { x=_x; y=_y; };
int getX() { return x; };
int getY() { return y; };
};

A.) int getY() { return y; };

void setValues(int _x, int _y) { x=_x; y=_y; };

int getX() { return x; };

D.) myClass();

B.)

void setValues(int _x, int _y) { x=_x; y=_y; };

C.)

int getX() { return x; };

D.) myClass();

Explanation / Answer

Ans)void setValues(int _x, int _y) { x=_x; y=_y; };

here With this function we can initialize the data memebers.When we call this function by using the Class instance.by passing the values as arguments.then those values will be initialized to the class instance variables.

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