I am new to C ++, and unfortunately, I can’t stop thinking about C # (my old language). I read several books, forums, and a C ++ help site, but I couldn’t find the answer to my question, so I thought that I could try here before giving up and writing something ugly.
Ok, we can start. I have a class with the succesorsFunction abstract method, and I would like it to return a collection of pointers to State . I do not want to force developers to a specific container; I prefer them to choose (vector, list, etc.).
So it looks like this:
class Problem { public: virtual list<const State*>::iterator succesorsFunction(const State &state, list<const State*>::iterator result) const = 0; };
the problem here is the explicit use of the list. How do you do this in C ++?
I thought about using templates, but then I ran into two problems: 1) It seems you cannot do this using abstract methods (or am I mistaken?) 2) How can I tell the template that it should contain state pointers?
source share