private constructor

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivek verma
    New Member
    • Feb 2010
    • 6

    private constructor

    Code:
    #include<iostream.h>
    #include<conio.h>
    class myclass()
    {
    int i;
    my class()
    {
    i=24;
    }
    public:
    void show()
    {
    cout<<i;
    }
    };
    void main()
    {
    //what should I write here to acess private constructor
    
    
    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You can't access a private constructor outside of the methods of the class itself so you can not write anything in main to access a private constructor.

    Additionally main returns int not void.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Please post your replies in the thread, do not use or reply to the PM

      Comment

      Working...