c++类 私有成员初始化_与C ++中的私有成员进行结构化

c++类 私有成员初始化As we know that by default, structures members are public by nature and they can be accessed anywhere using structure variable name. 我们知道,默认情况下,结构成员本质上是公共的,可以使用结构变量名在任何地方访问它们。 Sometimes ...
摘要由CSDN通过智能技术生成

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值