c++类 私有成员初始化
As we know that by default, structures members are public by nature and they can be accessed anywhere using structure variable name.
我们知道,默认情况下,结构成员本质上是公共的,可以使用结构变量名在任何地方访问它们。
Sometimes a question arose "Can a structure has private members?"
有时会出现一个问题: “结构可以有私人成员吗?”
The answer is "Yes! In C++, we can declare private members in the structure". So the important thing is that "we can declare a structure just like a class with private and public members".
答案是“是!在C ++中,我们可以在结构中声明私有成员” 。 因此,重要的是“我们可以像声明带有私有和公共成员的类一样声明结构” 。
Example:
例:
In this example, we are declaring a structure named "Student" which h