Problem with declaration of virtual function
From: Pierre Couderc (pierre_at_couderc.ccNOSPAM)
Date: 09/02/04
- Next message: Karl Heinz Buchegger: "Re: binary number"
- Previous message: romerun: "return reference to local variable ?"
- Next in thread: Alf P. Steinbach: "Re: Problem with declaration of virtual function"
- Reply: Alf P. Steinbach: "Re: Problem with declaration of virtual function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 02 Sep 2004 07:22:55 +0200
I have a problem with the declaration of virtual function. What do I do
wrong? Why the compiler (MS VC++ 6) says nothing?
It is very simple (see my comment below):
class A
{
public :
A(){;}
};
class B : public A
{
public :
B() : A() {;}
virtual void bad() {;}
};
class C : public B
{
public :
C() : B() {;}
void bad() {;}
};
BOOL CVirtuApp::InitInstance()
{
A* many[2];
C* p = new C;
ASSERT(_CrtIsValidHeapPointer(p));
many[0] = p;
ASSERT(_CrtIsValidHeapPointer(many[0])); // FAILS here
ASSERT(many[0]== p); // OK;
...
}
When the ASSERT fails, I see that the paramter of CrtIsValidHeapPointer
is XXXX at first call and XXXX+4 at second call.
So what am I doing wrong?
Thank you in advance
Pierre Couderc
- Next message: Karl Heinz Buchegger: "Re: binary number"
- Previous message: romerun: "return reference to local variable ?"
- Next in thread: Alf P. Steinbach: "Re: Problem with declaration of virtual function"
- Reply: Alf P. Steinbach: "Re: Problem with declaration of virtual function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|