>>158
//original function
results getTreasure(map room, char * treasureName, coord treasureLoc)
{
checkRoom(room);
//50 other statements go here
if (returnItem (room, treasureLoc) == treasureName)
return congratulations(treasureName);
else
failure();
}
//a different function but keeps the same interface
results getTreasure(map room, char * treasureName, coord treasureLoc)
{
path Path;
enterRoom (room);
path = calculatePath (treasureLoc);
if (path)
moveChar(path);
treasure = openTreasure();
if (treasure.name == treasureName)
return congratulations(treasureName);
else
return failure();
}
They both achieve the same goal but use a different means to achieve it. The interface to these functions (entry points and return points to the function) remain constant. The modified function implements it's own functions and does not call on any derived code. You can change the functionality of a program without deriving from the original.