C++ Dereferencing pointer to object -
i'm having trouble dereferencing pointer.
priority_queue<node*, vector< node*>, comparator>* pqueue = null; pqueue = h->addtoqueue(m); while (!pqueue->empty()) { cout << (*pqueue)->top() << endl; pqueue->pop(); }
addqueue(m)
returns pointer priority queue, when try print i'm getting memory address values.
any ideas why?
thanks..
you have overload <<
operator node class like:
ostream& operator<<(ostream& os, const node& nd) { os << nd.anyvalue; return os; }
also have dereference pointer like
cout << *pqueue->top()<< endl;
look @ example here:
https://msdn.microsoft.com/de-de/library/1z2f6c2k.aspx
or here:
http://www.tutorialspoint.com/cplusplus/input_output_operators_overloading.htm
Comments
Post a Comment