Introduction to OOP: Chapter 12: Implications of Inheritance [next] [previous] [audio] [real] [text]

Changing Method Arguments

Equality testing is one place where it frequently seems as if it would be nice if one could change the types of member function arguments. Consider the following:

class Shape {
public:
	boolean equals (Shape)
		{ return false; }
	...
};
class  Triangle : public Shape {
public:
	boolean equals (Triangle);
	...
};

class  Square : public Shape {
public:
	boolean equals (Square);
	...
};
Intro OOP, Chapter 12, Slide 16