/********************************************************************************** *** FILE: mo_friend.cpp *** DATE: Jan 21, 2004 *** AUTHOR: Daniel Dementiev *** GOAL: This is a short example illustrating friend functions in class *** definition. *** Designed for IST482 class. **********************************************************************************/ #include "mo_friend.h" MovingObject::MovingObject() { x = y = 0; speed = 1; dir = South; } void MovingObject::step() { switch( dir ){ case North: y += speed; break; case West: x -= speed; break; case South: y -= speed; break; case East: x += speed; break; } } int FindFastest(int count, MovingObject *obj) { int i, max_speed, ind; if( count < 0 ) return -1; max_speed = obj[0].speed; ind = 0; for(i=1;i