hi,

is it possible to declare constructors as private? if yes, will some one explain me how to do it or please provide some links regarding that.


thanks & regards
prasath

>is it possible to declare constructors as private?
Yes, and it provides some valuable functionality to do so occasionally.

>if yes, will some one explain me how to do it
Just place the constructor declaration in the private section rather than the public section:

class test {
public:
  test ( int init );
private:
  test();
};

In the test class, the single argument constructor is required by the outside world because it's the only one visible, but the implementation code of the test class can also use the default constructor.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.