0) Don't put using directives in header files. Doing so may subtly alter the way code compiles, and there is no way to undo it. Use fully qualified class names in header files instead.
1) Don't dynamically allocate members when its not necessary. The "name" member of the critter class should be a string instance, not a pointer. You are only making more work for yourself (and you aren't finished yet, you haven't followed the
Rule of Three).
2) If you have any virtual functions, the destructor should be made virtual too. Failure to do so could result in the destructor not being called.
3) std::endl combines newline and a buffer flush. Use the character constant '\n' when you just want to put a newline. Its usually quicker to type too [smile]
4) Don't use inline like that. Compilers are free to ignore inline. The only time inline is necessary is when implementing a free function in a header file. Class functions can be made inline by writing the body inside the class.
5) I find it suspicious that the iterator is a member of the Farm. It should probably be a local variable.
6) Can we see the declaration of the Farm class?
From the above, the critter class could look like this:
#include <iostream>#include <string>class Critter{public: string GetName() { return name; }; virtual void Speak() { std::cout << "Here.\n"; }protected: std::string name; Critter( const string &name ) : name(name) {} virtual ~Critter() {}};