2

我有这样的声明

#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
}

但是我从 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);

有趣的是,如果我使用备用朋友声明(明确指定方法)它是否有效?关于为什么它们不同的任何想法?

顺便说一句,使用英特尔 C++ 编译器 11.1.065。

4

1 回答 1

0

你的小应该t是资本TP**t**PathWriter

于 2010-08-23T15:53:50.607 回答