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???

Recommended Answers

All 2 Replies

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.

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();

?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.