[英]Member is inaccessible from friend class
I have a declaration like this 我有这样的声明
#include "Output/PtPathWriter.h"
// class PtPathWriter // I've also tried forward declaring the friend class
// leg data is a class designed to hold data for a single leg.
class PtPathLeg
{
friend class PtPathWriter; // doesn't work
//friend void PTPathWriter::writeToFile(string fileName, PtPath* path); // works
protected:
vector<map<int, shared_ptr<BoardingStopAlternative>>> m_boarding_stop_alternatives;
// some other stuff
}
However I get an error from PtPathWriter saying 但是我从PtPathWriter得到一个错误说
PtPathWriter.cpp(44): error #308: member "PtPathLeg::m_boarding_stop_alternatives" (declared at line 79 of "../include/Paths/PtPathLeg.h") is inaccessible
1> path->m_leg_data.at(legnr).m_boarding_stop_alternatives.at(stopId);
Interestingly, if I use the alternate friend declaration (which specifies the method explicitly) it does work? 有趣的是,如果我使用备用的朋友声明(明确指定方法),它是否有效? Any thoughts on why they are different?
关于它们为何与众不同的任何想法?
Using Intel C++ Compiler 11.1.065 btw. 使用Intel C ++编译器11.1.065 btw。
您的小t
应该是P**t**PathWriter
的大写T
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.