Question: What is the output when Q 2 ( ) is invoked? class Q 1 class { private: Int myPrivateInt; public: Q 1 class ( int

What is the output when Q2() is invoked?
class Q1class
{
private:
Int myPrivateInt;
public:
Q1class(int x)
{
myPrivateInt = x;
}
Q1Class (){ myPrivateInt =42; }
void add (int x);
int getVal(){ return myPrivateInt; }
void decrement (int i=1)( myPrivateInt -= i; }
};
void Q2()
{
Q1class q;
int y = q.myPrivateInt;
cout << y / y;
}
Group of answer choices
0
1
42
Division by zero exception
Compilation error due to accessing a private member

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!