Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

C++ | Constructors | Question 3

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Output of following program? 


#include < iostream ><br>
using namespace std;<br>
class Point {<br>
Point() { cout << \"Constructor called\"; }<br>
int main()<br>
Point t1;<br>
return 0;<br>


Runtime Error


None of these


Constructor called


Compiler Error

Answer: (D)


By default all members of a class are private. Since no access specifier is there for Point(), it becomes private and it is called outside the class when t1 is constructed in main. 

Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 02 Dec, 2021
Like Article
Save Article
Similar Reads