MCQ-OOPs question doubt

Q­3 Predict the output?
#include using namespace std;
class Test {
int x; Test() {
x = 5;
}
};
int main() {
Test *t = new Test;
cout << t­>x;
}
A) 0
B) 5
C) Garbage value
D) Compiler error

why is D answer?

@Vibhuti0206 hey there is two error in the code the first one is that the data member is private so it can’t access even after object creation so declare it as public and the syntax of cout statement is also not right.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.