Dear all,
I have got a difficult question to point out all the problems in the following C++ header code segments. Could any C++ expert please 'enlight' me?
Thanks a lot,
miss muichu
Code:
/**\file pets.hpp
* Classes to model members of household: the pet cat(s) and dog(s)
*
*/
// Forward declarations to avoid including <iostream.h>
namespace std
{
template<class _E> struct char_traits;
template<class _E, class _Tr> class basic_ostream;
typedef basic_ostream<char, char_traits<char> > ostream;
}
using namespace std;
class mouse; // Mice are peats not pets!
class location;
class collar;
/// Pet cat
class cat
{
public:
void go_to(location& destination);
/// @return nul if fails
mouse* stalk();
/// Where are
location where() const;
/// @return true if the cat comes when called
virtual bool dinner_time();
/// put collar on
virtual set_collar(collar* new_collar);
/// Get the cat's collar
virtual collar* getCollar() const;
void purr (ostream& out);
private:
// Data members ommitted
};
/// Pet cat
class dog : public cat
{
public:
// inherits go_to() and where() from cat
/// @return nul if fails
mouse* stalk();
cat* chase_cat(cat* the_cat);
void purr(ostream& out) { throw "dog don't purr"; )
void bark(ostrea,& out);
void walkies();
/// put collar on
virtual set_collar(collar* new_collar);
virtual bool dinner_time() { return true; }
private:
// Data members ommitted
};