C++ | Constructors | Question 3
Output of following program?
#include<iostream> using namespace std; class Point { Point() { cout << "Constructor called"; } }; int main() { Point t1; return 0; } |
chevron_right
filter_none
(A) Compiler Error
(B) Runtime Error
(C) Constructor called
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
Recommended Posts:
- C++ | Constructors | Question 15
- C++ | Constructors | Question 6
- C++ | Constructors | Question 10
- C++ | Constructors | Question 17
- C++ | Constructors | Question 1
- C++ | Constructors | Question 16
- C++ | Constructors | Question 2
- C++ | Constructors | Question 5
- C++ | Constructors | Question 14
- C++ | Constructors | Question 4
- C++ | Constructors | Question 7
- C++ | Constructors | Question 8
- C++ | Constructors | Question 17
- C++ | Constructors | Question 12
- C++ | Constructors | Question 13



