Short version:
class MyClass
{
friend class MyOtherClass::MySubClass; // Doesn't work
};
class MyOtherClass
{
class MySubClass
{
// Need to access private members of MyClass here
} MySubInstance;
};
Here is something more close to what I am trying to do showing the problem:
#include <iostream>
#include <string>
class COffsetMap
{
public:
void SetBase( void* Base ) { }
void SetOffset( int& Var ) { }
};
class CHealth
{
public:
friend class CCharacter::CCharFieldMap; // Doesn't work
private:
int Mana_;
int ManaMax_;
};
class CCharacter
{
public:
class CCharFieldMap: public COffsetMap
{
public:
void SetMap( CCharacter* Base )
{
SetBase( Base );
SetOffset( Base->Version );
SetOffset( Base->Health.Mana_ ); // Can't access private
SetOffset( Base->Health.ManaMax_ ); // Can't access private
}
} CharFieldMap;
private:
int Version;
CHealth Health;
};
int main()
{
CCharacter Char;
std::cout << "Press Return";
std::string wait;
std::getline( std::cin, wait );
return 0;
}
I've tried various ways around this to no avail. Is this possible?