Declaration of virtual function.
From: Pierre Couderc (pierre_at_couderc.ccNOSPAM)
Date: 09/01/04
- Next message: Tim Slattery: "Re: how to printf"
- Previous message: Harvey: "Disable long name preservation for old programs"
- Next in thread: Adrian ~ FoobarSoftware.com: "RE: Declaration of virtual function."
- Reply: Adrian ~ FoobarSoftware.com: "RE: Declaration of virtual function."
- Reply: Richard Lewis Haggard: "Re: Declaration of virtual function."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 01 Sep 2004 21:13:57 +0200
I have a problem with the declaration of virtual function. What do I do
wrong? Why the compiler 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: Tim Slattery: "Re: how to printf"
- Previous message: Harvey: "Disable long name preservation for old programs"
- Next in thread: Adrian ~ FoobarSoftware.com: "RE: Declaration of virtual function."
- Reply: Adrian ~ FoobarSoftware.com: "RE: Declaration of virtual function."
- Reply: Richard Lewis Haggard: "Re: Declaration of virtual function."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|