In which access should a constructor be defined, so that object of the class can be created in any function?

Danh Trịnh

New member
In which access should a constructor be defined, so that object of the class can be created in any function?
A. Public
B. Protected
C. Private
D. Any access specifier will work
 
Answer: a
Explanation: Constructor function should be available to all the parts of program where the object is to be created. Hence it is advised to define it in public access, so that any other function is able to create objects.
 

Tìm kiếm

Back
Top