大家讲道理2017-04-17 15:03:33
protected and private. Constructors and destructors, as well as static member functions and friend member functions (rarely used) can be protected or even private.
Private constructors do not allow external objects to be constructed directly, while classes can provide specialized factory methods or singleton methods to construct objects.
黄舟2017-04-17 15:03:33
The members of the C++ class include these:
构造和析构
(Public by default, not public, how to create and destroy it?)
public
are shared. (Can be called externally)
The methods and variables described by protect
are protected. (Not callable from outside)
private
Described methods and variables, private (not callable from outside)
static
do not belong to any object, but belong to the entire class. The calling method is 类名::方法|变量
friend
describes methods and variables, commonly used friend functions. In order to make member functions of other classes access the private members of the class.
Basically these. I think the non-public properties of C++ should be except for public
, that is, 3, 4, 5, 6.