Hi ..
A basic template and pointer question for you.
I have a set of classes that look like (simplified):
class Foo {
public:
Foo *next;
Foo *other;
int n;
friend class FooList;
};
class FooList {
vector<Foo> foos;
void add(); // add a foo to the list
};
void FooList::add() {
Foo f = new Foo();
f->n = foos.size();
Foo *fp = foos.end(); // get the last added foo to link the pointers
if (fp != (Foo*)NULL)
fp->next = &f;
foos.push_back(f);
}
My problem is that the 'Foo *fp = foos.end();' is illegal.
How go I get the last item as it is stored?
Regards,
--
-mark. (probertm at acm dot org)