Skip to content
Related Articles

Related Articles

C++ | Constructors | Question 3

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 02 Dec, 2021

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>

(A) Compiler Error
(B) Runtime Error
(C) Constructor called
(D) None of these

Answer: (A)

Explanation: 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!