我在我們的使用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