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? if yes, will some one explain me how to do it or please provide some links regarding that.
Here's one link
http://gethelp.devx.com/techtips/cpp_pro/10min/10min0200.asp
>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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.