Re: [C++] Templates and inheritance

From: Alwyn (dt015a1979_at_mac.com.invalid)
Date: 09/28/04


Date: Tue, 28 Sep 2004 17:47:41 +0100

In article <slrncliuer.usv.hexkid@ID-203069.user.uni-berlin.de>, Pedro
Graca <hexkid@hotpop.com> wrote:

> What am I missing?

<snip>

> void my_push(const T& x) {
> if (top() > x) {

This is the problem. An empty stack has no 'top' value. Stupidly, the
implementation allows the program to crash rather than raise an
exception to indicate the mistake.

Alwyn



Relevant Pages