abstract classes not detected by compiler
From: Bjorn (bjed_at_tss.teleca.se)
Date: 10/25/04
- Next message: Hilla: "Re: Problem with Event sending using ATL"
- Previous message: Paul Lutus: "Re: C to Java Byte Code"
- Next in thread: Karthik Kumar: "Re: abstract classes not detected by compiler"
- Reply: Karthik Kumar: "Re: abstract classes not detected by compiler"
- Reply: Thomas Maier-Komor: "Re: abstract classes not detected by compiler"
- Reply: Victor Bazarov: "Re: abstract classes not detected by compiler"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 25 Oct 2004 15:14:44 +0200
I'm using interfaces in C++ by declaring classes with only pure virtual
methods. If then someone wants to implement the interface they
needs to inherit from the class. If the implementing class forgets to
implement some method I normally get a compile error(if the class is created
in some way of course). When using the Visual
Studio 6 compiler however, it does not generate a compile error in this
case:
- I have a implementing class A that inherits from an interface class. It
has not implemented all methods.
- The implementing class A is declared as an array in a container class. The
container class is created with new.
The compiler do not generate any errors, but I will of course get a runtime
error when a method with no implementation is called("pure function call" or
something). If the container class declares A as a pointer(and performs new
on it) or as a non-array variable, then the compiler generates compile
errors, but not if it is declared as an array.
So, my question is: is it a compiler fault, if it does not find out that an
abstract class is created(which is the case here since all methods are not
implemented)? Or should it be considered as normal that the compiler can not
find out cases like this(i.e more complicated cases).
/Bjorn
- Next message: Hilla: "Re: Problem with Event sending using ATL"
- Previous message: Paul Lutus: "Re: C to Java Byte Code"
- Next in thread: Karthik Kumar: "Re: abstract classes not detected by compiler"
- Reply: Karthik Kumar: "Re: abstract classes not detected by compiler"
- Reply: Thomas Maier-Komor: "Re: abstract classes not detected by compiler"
- Reply: Victor Bazarov: "Re: abstract classes not detected by compiler"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|