The constructors, destructors declared as private and protected, then how to create objects

Can not call a constructor from the outside, but the object must be constructed, how to solve the trouble we help instructions on configuration, usage destructor is declared when the private and protected? ? ?
 
He raised the issue, indicating that you have been thinking for a c ++. 

Grammatically speaking, a function is declared as protected or private, then this function is not from "outside" to be called directly. 
For functions protected, the "inside" subclass of the other functions can be called. 
For a private function, this class can only be "inside" the other said function call. 

Grammar is so specified, you must also know slightly. 
So why sometimes the constructor or destructor is declared as a protected or private? 

Scene generally used as follows: 
1. If you do not want outside users to directly construct a class (assuming the name of the class is A) of the object, the user can only hope to construct this subclass of class A, then you can be the constructor of the class A / destructor declared as protected, and the constructor subclass of class a / destructor declared as public. E.g:

Guess you like

Origin www.cnblogs.com/hshy/p/12013602.html