0

okay , i see ....

i have situation where i have a list called bunnyList containing mutantType objects, i want to create a new object using a constructor and add this object to my list. Like below.

bunnyList.push_front( new mutantType );


with the aid of the newly discovered rbegin pointer i want to look at the last object in the list i've just added and execute a member function from that object....-mutantType. In this case mutantType::printsummary().

J is my reverse iterator


J= bunnyList.rbegin();
(*j)-> printSummary();

I want to put all this in a for..next loop . Although i get no warnings or compiling errorss, i suspect something is going wrong??. As the loop cycles
J= bunnyList.rbegin(); points to the newly added object.

I there anything wrong with this approach???

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by arkoenig
0

Well it sounds like you are creating a linked list, and if you are trying to call a function from the last object that was added, what I would do is keep track of how many objects you have added to the list using an int var, and then use that variable to iterate to the last object that was added and then call your function. Sorry if I'm misunderstanding your question. But if you arn't having any problems compiling, try debugging your program to see if anything is happening that you don't want to happen.

0

I don't see anything wrong with what you've written, provided that j is in fact an object of the appropriate reverse iterator type. However, I wonder why you're not just writing

bunnyList.last()->printSummary();

?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.