Results 1 to 2 of 2

Thread: Use private constructor in C++

  1. #1
    MoralesWard is offline Senior Member
    Join Date
    Dec 2009
    Posts
    176
    Rep Power
    3

    Default Use private constructor in C++

    I began learning c++ language. I want to know about private constructor. So please tell me about use of private constructor in C++. Any help will be appreciated.

  2. #2
    JenkinsReed is offline Senior Member
    Join Date
    Dec 2009
    Posts
    169
    Rep Power
    3

    Default

    Private constructor is utilized in c++ to make object of class single time. Means your class doesn’t have more that one instance of class. See code given below to understand it.

    Code:
    class MyClassEg()
    { private:
      	MyClassEg() { }
    	  	public:
      	MyClassEg & Instances()
      	{    static MyClassEg * aGlobalInsts = new MyClassEg();
        return *MyClassEg;
      	} };

Similar Threads

  1. Keep folders private (XP)
    By elzer25 in forum Windows XP
    Replies: 0
    Last Post: 03-30-2009, 10:16 AM
  2. Keep files private
    By andressa143 in forum Everything Else
    Replies: 1
    Last Post: 03-17-2009, 10:59 AM
  3. Private Server
    By ABEDNEGO87 in forum General Internet Terms
    Replies: 0
    Last Post: 03-09-2009, 11:06 AM
  4. Private files
    By qeintine641 in forum CPU & Components
    Replies: 1
    Last Post: 12-02-2008, 09:48 AM
  5. Look for private data
    By widstone in forum Everything Else
    Replies: 0
    Last Post: 06-23-2008, 12:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48