T
TheFerryman
The easiest way to describe this is with some code. In the following,
I would like the Thingalator::Func method to be able to access the
private member variable Thing::m_TList. Is it possible to make
Thingalator a friend of Thing? If so how?
Many thanks
//---------------------------------------------------------------------
#include <list>
template <class T>
class Thing
{
public:
typedef std::list<T> TList;
private:
TList m_TList;
public:
Thing(){}
};
template <class thing_type>
class Thingalator
{
thing_type m_Thing;
public:
void Func()
{
thing_type::TList local = m_Thing.m_TList;
}
};
int main()
{
Thingalator<Thing<int> > t;
t.Func();
return 0;
}
//---------------------------------------------------------------------
I would like the Thingalator::Func method to be able to access the
private member variable Thing::m_TList. Is it possible to make
Thingalator a friend of Thing? If so how?
Many thanks
//---------------------------------------------------------------------
#include <list>
template <class T>
class Thing
{
public:
typedef std::list<T> TList;
private:
TList m_TList;
public:
Thing(){}
};
template <class thing_type>
class Thingalator
{
thing_type m_Thing;
public:
void Func()
{
thing_type::TList local = m_Thing.m_TList;
}
};
int main()
{
Thingalator<Thing<int> > t;
t.Func();
return 0;
}
//---------------------------------------------------------------------