Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on constructor within the C and C++ forums, part of the Software Development category; hai every body, how can we create an instance of a class , having the constructor with the private access specifier......... pls can any body tell me the answer.......... Thanks ...
|
|||||||
|
|||
|
constructor
hai every body,
how can we create an instance of a class , having the constructor with the private access specifier......... pls can any body tell me the answer.......... Thanks in Advace ........... Regads mallik |
| Sponsored Links |
|
|||
|
Re: constructor
The private constructor can be called from a static member of that class. Like:
class ClassA{ ClassA(); public: static void* create(){return new ClassA();}}; Another reason for a private constructor is to hide a default constructor and to force the class user to construct it using a constructor with arguments. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Which constructor will be called in main | sandhyatammala | OOPS | 27 | 04-10-2009 11:28 PM |
| Constructor in place of init() method | Lokesh M | Java | 1 | 01-31-2008 03:43 PM |
| Icon Constructor converts images of any format into Windows icons. | JobHelper | Geeks Lounge | 0 | 02-27-2007 09:20 AM |