/************************************************************************
 *
 * Purpose: Show the use of the :: operator to identify methods 
 *          outside the class definition.
 * Author:  M J Leslie
 * Date:    01-May-00 Rev 1
 *
 ************************************************************************/


#include <iostream.h>

// Define the Animal class

class Animal
{
public:
    
    int  GetNumOfLegs(void); 	// Declare a couple of methods
    void SetNumOfLegs(int L);

private:
    
    int Legs;
};

// Define the methods. The :: operator associates the method with
// the correct class.

int Animal::GetNumOfLegs(void)
{
    return Legs;
}

void Animal::SetNumOfLegs(int L)
{
    Legs = L;
}

// **************************************************************

main()
{
    Animal Goat;		// Create the goat object

    Goat.SetNumOfLegs(4);	// Initialise the Goat object with some legs

				// Inform the user how many legs a goat has.
    cout << "Goats have " 
         << (int) Goat.GetNumOfLegs() 
         << " legs" 
         << endl;

    exit(0);
}

/********************************************************
 *
 *  Result
 *
 *  Goats have 4 legs
 *
 ********************************************************/


