C++ | Constructors | Question 3
Output of following program?
<br> #include < iostream ><br> using namespace std;<br> class Point {<br> Point() { cout << "Constructor called" ; }<br> };<br><br> int main()<br> {<br> Point t1;<br> return 0;<br> }<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