Click here to Skip to main content
16,008,750 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Humm, is this right? Pin
Masaaki Onishi22-Jul-01 4:28
Masaaki Onishi22-Jul-01 4:28 
GeneralRe: Humm, is this right? Pin
nulldreamer22-Jul-01 10:46
nulldreamer22-Jul-01 10:46 
GeneralRe: Well... Pin
Masaaki Onishi22-Jul-01 12:49
Masaaki Onishi22-Jul-01 12:49 
GeneralRe: Humm, is this right? Pin
Andrew Peace22-Jul-01 13:59
Andrew Peace22-Jul-01 13:59 
GeneralCStringArray Pin
Michael Martin21-Jul-01 21:55
professionalMichael Martin21-Jul-01 21:55 
GeneralRe: CStringArray Pin
Anders Molin22-Jul-01 3:53
professionalAnders Molin22-Jul-01 3:53 
GeneralRe: CStringArray Pin
Michael Martin22-Jul-01 4:04
professionalMichael Martin22-Jul-01 4:04 
GeneralObject Oriented DLL Problem Pin
21-Jul-01 21:35
suss21-Jul-01 21:35 
I am trying to package a reusable class library in a win32 dll
however I have run into a problem,
Class B and B2 derive from class A, heres the simplified code:
class __declspec( dllexport ) A
{
public:
A();
virtual ~A();
virtual void SomeFunc(void) = 0;
};

class __declspec( dllexport ) B : public A
{
public:
B();
virtual ~B();
void SomeFunc(void);
};

class __declspec( dllexport ) B2 : public A
{
public:
B2();
virtual ~B2();
void SomeFunc(void);
};

A::A()
{
cout << "A constructor." << endl;
}

A::~A()
{
cout << "A destructor." << endl;
}

B::B()
{
cout << "B constructor." << endl;
}

B::~B()
{
cout << "B destructor." << endl;
}

void B::SomeFunc(void)
{
cout << "B::SomeFunc()" << endl;
}

B2::B2()
{
cout << "B2 constructor." << endl;
}

B2::~B2()
{
cout << "B2 destructor." << endl;
}

void B2::SomeFunc(void)
{
cout << "B2::SomeFunc()" << endl;
}

This compiles into a DLL without any problems. However when
I attempt to use it (I have linked to the .lib and put the
.dll in the executable directory) using the following code:

#include "A.h"
#include "B.h"
#include "B2.h"

int main(void)
{
A* test = NULL;
test = new B();
test->SomeFunc();
delete test;

return 0;
}

I get the output as expected:
A constructor.
B constructor.
B::SomeFunc()
B destructor.
A destructor.

But then a nasty debug assertion failure:
Debug Asserion Failed.
File: dbgheap.c

Expression: _pFirstBlock == pHead

Oddly enough, if I comment out delete test; the assertion failure does not occur, but I dont want memory leaks in my programs. I know that converting it too a COM dll and using interfaces would problably be the best solution, however I want to first learn how to create normal dlls before I mess with making them COM compliant.
GeneralRe: Object Oriented DLL Problem Pin
21-Jul-01 21:59
suss21-Jul-01 21:59 
GeneralRe: Object Oriented DLL Problem Pin
Joaquín M López Muñoz22-Jul-01 5:39
Joaquín M López Muñoz22-Jul-01 5:39 
QuestionCHttpServer Class? Pin
dark12021-Jul-01 15:54
dark12021-Jul-01 15:54 
AnswerRe: CHttpServer Class? Pin
Not Active22-Jul-01 10:25
mentorNot Active22-Jul-01 10:25 
GeneralQuestion about Interdev Pin
21-Jul-01 14:47
suss21-Jul-01 14:47 
GeneralRe: Question about Interdev Pin
Anders Molin22-Jul-01 3:57
professionalAnders Molin22-Jul-01 3:57 
GeneralPlease help me to fix a bug in Windows XP. Pin
21-Jul-01 14:09
suss21-Jul-01 14:09 
GeneralRe: Please help me to fix a bug in Windows XP. Pin
Michael Martin21-Jul-01 22:32
professionalMichael Martin21-Jul-01 22:32 
GeneralMFC icons Pin
Stephen McGeown21-Jul-01 13:27
Stephen McGeown21-Jul-01 13:27 
GeneralRe: MFC icons Pin
Michael Martin21-Jul-01 23:00
professionalMichael Martin21-Jul-01 23:00 
GeneralRe: MFC icons Pin
Stephen McGeown22-Jul-01 4:11
Stephen McGeown22-Jul-01 4:11 
GeneralLong Number Storage for Encryption Pin
Peter Liddle21-Jul-01 12:40
Peter Liddle21-Jul-01 12:40 
GeneralExtending SIP Pin
21-Jul-01 10:50
suss21-Jul-01 10:50 
GeneralRe: Extending SIP Pin
Anders Molin21-Jul-01 11:34
professionalAnders Molin21-Jul-01 11:34 
GeneralRe: Extending SIP Pin
21-Jul-01 12:37
suss21-Jul-01 12:37 
GeneralRe: Extending SIP Pin
Anders Molin21-Jul-01 12:45
professionalAnders Molin21-Jul-01 12:45 
GeneralExtending SIP Pin
21-Jul-01 10:46
suss21-Jul-01 10:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.