Geeks Talk

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.

constructor

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 ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 03-29-2007
Junior Member
 
Join Date: Mar 2007
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
emb.mallik is on a distinguished road
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-02-2009
Junior Member
 
Join Date: Mar 2009
Location: Washington, DC
Posts: 10
Thanks: 0
Thanked 3 Times in 1 Post
u6022 is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 02:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved