Results 1 to 2 of 2

Thread: constructor

  1. #1
    Junior Member
    Join Date
    Mar 2007
    Answers
    1

    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


  2. #2
    Junior Member
    Join Date
    Mar 2009
    Answers
    10

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact