I have a Container-Class and inside a Pointer-Class. The Container-Class has a private variable (myTreeSize), which I need also for the Pointer-Class. I tried to use reference or friend, but it won't work. Maybe someone has an idea?
template <typename Key>
class myContainer{
class myPointer;
using littlePoint = myPointer;
private:
struct node{
//....
};
struct mylist{
//....
};
mylist* tree{nullptr};
size_type myTreeSize{0};
public:
littlePoint find(int key) {
mylist *list_pos{find_list(key)}; //return list-position
node *node_pos {find_node(key)}; //return node-position
if (list_pos && node_pos) return littlePoint{list_pos, node_pos};
return end();
}
//.....methods
};
template <typename Key>
class myContainer<Key>::myPointer{
mylist *list_pos;
node *node_pos;
myContainer& parent; //<--- no private variables
friend class myContainer; //<-- no effect
explicit myPointer(mylist *list_pos=nullptr, node *node_pos = nullptr):
list_pos{list_pos}, node_pos{node_pos} {
//...
}
}