I believe one cannot do that because of compiler reasons... but anyway, can anyone help me solve the idea?
I would like to create a node and, when passing the element for it as a reference, avoid copying it. I just want to copy the reference to that element to save time. It'd be something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
template <class A>
class Node{
public:
Node(const A& element);
~Node();
private:
Node<A>* prev;
Node<A>* next;
A elem; // I would like this to be "A& elem", but I cannot initialize it yet.
};
template <class A>
Node<A>::Node(const A& element){
this->prev = NULL;
this->next = NULL;
this->elem = element; // This is what I want to avoid, how could I do "&(this->elem) = element" ?
}