Predict the output?
(A) Compiler Error
(C) Garbage Value
Explanation: There is compiler error: Test::Test() is private.
new makes call to the constructor. In class Test, constructor is private (note that default access is private in C++).
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- C++ | new and delete | Question 1
- C++ | new and delete | Question 4
- C++ | new and delete | Question 5
- C++ | new and delete | Question 2
- "delete this" in C++
- delete and free() in C++
- C program to delete a file
- new vs malloc() and free() vs delete in C++
- C | String | Question 14
- C++ | Constructors | Question 16
- C++ | this pointer | Question 2
- C++ | this pointer | Question 1
- C++ | Constructors | Question 9
- C++ | Destructors | Question 3
- C++ | Constructors | Question 8