Pet Class Reference

#include <pet.h>

Inheritance diagram for Pet:

Cat Dog

List of all members.

Public Member Functions

 Pet ()
 Pet (string name, double age) throw ( out_of_range )
void setName (string name)
void setAge (double age) throw ( out_of_range )
string getName () const
double getAge () const
virtual void print (ostream &out=cout) const
virtual void read (istream &in) throw ( out_of_range )
virtual ~Pet ()

Protected Attributes

string name
double age


Detailed Description

Pet class for storing information about pet, which has a name and an age.

Author:
Mark Maloof
Version:
1.1, 7/21/10

Constructor & Destructor Documentation

Pet::Pet (  ) 

Default constructor.

Pet::Pet ( string  name,
double  age 
) throw ( out_of_range )

Explicit class constructor initializing a pet object using the arguments name and age.

Parameters:
name a string storing the name of this pet
age a double storing the age of this pet
Exceptions:
out_of_range if the age is out of range

Pet::~Pet (  )  [virtual]

Destructor. Does nothing but is recommended for classes with virtual methods.


Member Function Documentation

void Pet::setName ( string  name  ) 

Sets this pet's name

Parameters:
name a string storing this pet's name

void Pet::setAge ( double  age  )  throw ( out_of_range )

Sets this pet's age

Parameters:
age a double storing this pet's age

string Pet::getName (  )  const

Returns this pet's name

Returns:
a string storing this pet's name

double Pet::getAge (  )  const

Returns this pet's age

Returns:
an int storing this pet's age

void Pet::print ( ostream &  out = cout  )  const [virtual]

Prints this pet's name and age to the ostream out, which defaults to cout.

Parameters:
out an ostream for printing (defaults to cout)

Reimplemented in Cat, and Dog.

void Pet::read ( istream &  in  )  throw ( out_of_range ) [virtual]

Reads this pet's name and age from the istream, storing them in the respective data members.

Parameters:
in an istream for reading
Exceptions:
out_of_range if age is out of range

Reimplemented in Cat, and Dog.


Member Data Documentation

string Pet::name [protected]

double Pet::age [protected]


The documentation for this class was generated from the following files:

Generated on Thu Jul 29 11:29:33 2010 by  doxygen 1.5.5