Skip to content
Related Articles

Related Articles

C++ | Constructors | Question 3
  • Difficulty Level : Easy
  • Last Updated : 16 Mar, 2013

Output of following program?

using namespace std;
class Point {
    Point() { cout << "Constructor called"; }
int main()
   Point t1;
   return 0;

(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

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :