我在我们的使用C++的信号类中有这个项目。我跟我们的教官代码修修补补,当我看到这一点:C++私有成员可访问吗?
ListData::ListData(const ListData& newlist)
: Data(), nbNodes(newlist.nbNodes) {}
这是一个“拷贝构造函数”,他说,应该是大致等同于以下内容:
ListData::ListData(const ListData& newlist){
Data = "";
//copy nbNodes of newList to current instance
nbNodes = newlist.nbNodes;
}
但让我困扰是nbNodes
是私人会员。 如果它是私密的,这个构造函数如何访问通过的newList
的nbNodes
?
你总是你自己最好的朋友:http://stackoverflow.com/a/437507/14065 – 2013-02-27 15:38:48