如何在c ++中通过构造函数访问类访问中的私有成员 [英] how to access private member in class access by constructor in c++
本文介绍了如何在c ++中通过构造函数访问类访问中的私有成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不使用复制构造函数..........
Without use copy constructor ..........
推荐答案
您可以封装变量示例:
< a href =http://www.tutorialspoint.com/cplusplus/cpp_data_encapsulation.htm> http://www.tutorialspoint.com/cplusplus/cpp_data_encapsulation.htm [ ^ ]
或者你可以创建设置和获取变量的方法
You can encapsulate your variables example:
http://www.tutorialspoint.com/cplusplus/cpp_data_encapsulation.htm[^]
or you can create methos to set and get variables
这篇关于如何在c ++中通过构造函数访问类访问中的私有成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文