[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[LC++]Pure Virtual Functions and Derived Classes



Is is true that where you have a pure virtual function in a base class,
your derived classes _must_ contain a definition of that virtual
function? Sample code:

class alpha
{
private:
	int x;
public:
	alpha() {x = 0;}
	virtual void increment();
	virtual void decrement();
	virtual void turn_sideways() = 0;
};

class bravo : public alpha
{
public:
	void increment() { x += 1; }
	void decrement() { x -= 1; }
	// notice no reference to turn_sideways()
};



Paul