Computer Applications
Constructor functions obey the usual access rules. What does this statement mean ?
Answer
Constructor functions obey the usual access rules. It means that a private or protected constructor is not available to the non-member functions.
With a private or protected constructor, one cannot create an object of the same class in a non-member function. Only the member functions of that class can create an object of the same class and invoke the constructor.
Related Questions
Define a constructor function for a Date class that initializes the Date objects with given initial values. In case initial values are not provided, it should initialize the object with default values.
What condition(s) a function must specify in order to create objects of a class ?
How are parameterized constructors different from non-parameterized constructors?
What are benefits/drawbacks of temporary instances ?