Hi, what I'm trying to do is call my validate() method from inside another method but it won't compile and I'm not sure why.. I'm pretty new at this.

Here is my validate():

ListNode* validate(const Position<T>* pos) const throw(PositionInvalidException) {
Position<T>* tmp = const_cast<Position<T>*>(pos);
ListNode* tmp2 = dynamic_cast<ListNode*>(tmp);
if (tmp2.head != NULL && tmp2 == ListNode().container_)
throw PositionInvalidException("position");
else
return tmp2->head();
}

and here is where I want to call it from:

virtual Position<T>* prev(const Position<T>* pos) const throw(ListBoundaryException, PositionInvalidException) {
ListNode* tmp = validate(pos);
return tmp->prev();
}

The error it gives is:

instantiated from `Position<T>* ListDL<T>:rev(const Position<T>*) const [with T = std::string]'

and it refers to the "ListNode* tmp = validate(pos);" line.

I have no idea what the error means, Any hints or pointers would be muchly appreciated

Oh sorry, here it is.

In member function `ListDL<T>::ListNode* ListDL<T>::validate(const Position<T>*) const [with T = std::string]': instantiated from `Position<T>* ListDL<T>::prev(const Position<T>*) const [with T = std::string]' instantiated from here comparison between distinct pointer types `ListDL<std::string>::ListNode*' and `ListDL<std::string>*' lacks a cast request for member `head' in `tmp2', which is of non-class type `ListDL<std::string>::ListNode*'

Hi!

I think the function that u called do not able fine the return type, You can try this out, May it work.
ListNode* tmp = (ListNode*)validate(pos);

This article has been dead for over six months. Start a new discussion instead.