Well here's my take on it, still not convinced I've understood you. My best
guess is that you are hung up on something which is a non-issue.
"verbatime" <no****@nospam.tk> wrote in message
news:40*********************@dread12.news.tele.dk. ..
Okay its also pretty hard to explain i think:
My architecture is a main application, that uses a DLL - that calls back
to the main application. The DLL supplies access to its class (bcQueue) - and
the mainapplication supplies (via passing a pointer to the DLL) access to
its bcGlobal class.
Thats the reason i have the virtual functions anyway, because they are
defined in the DLL, and not in the headerfile, since the code is to be
loaded in runtime, and the code can differ from DLL to DLL.
What i have is a baseclass defined in "plugin.h" - with pure virtual
functions - the reason why, is that "plugin.h" is included in both in the
main and in the dll (code should be defined in DLL - but not in the main):
// base class
class bcQueue
{
public:
int queuesize;
int nrOfClients;
char sfilename[200];
virtual bool AddIPentry (ipentry *entry) { }
virtual int getIPentryindex (void) {}
}
There are no pure virtual functions in this code, despite what you say.
The function-code are NOT defined in this "plugin.h" - because the code
itselfs is in a DLL - the baseclass is only meant to be a skeleton, so the
both the main application & the DLL understand the structure.
So the main application - when looking at the bcQueue - can only see what
variables and functions it consist of - it doesnt know anything about the
code that resides inside the functions.
What i want (and trying to explain) is how i can define the code for this
structure - in plugin.cpp (which is the DLL) ?
My way was to make a new class, which looked exactly the same:
cQueue : public bcQueue
But that doesnt work,
This is the problem, what do you mean by 'doesn't work', does it not
compile, does it not run correctly?
because then ex. the variables are the one from the
new class, and not the one's from the baseclass - that gives problems when
using pointers ofcourse.
So i think its very fundemental what im trying to ask - but is very very
hard to put it down with words ?
But if you get the idea that i have a DLL and the defintion placed
differently places, then it might lead you on track ?
As it happens all C++ programs have definitions placed in different places.
When you include a header file in two different source files you are getting
two (identical) definitions in two different places. As long as the
definitions are identical, C++ can cope. I haven't read anything in your
description that suggest you want the same class defined *differently* in
two different places. If that is what you do want then that's a whole
different ball game.
Seems like the following should work perfectly well.
class bcQueue
{
public:
int queuesize;
int nrOfClients;
char sfilename[200];
virtual bool AddIPentry (ipentry *entry) = 0;
virtual int getIPentryindex (void) = 0;
};
class cQueue : public bcQueue
{
public:
virtual bool AddIPentry (ipentry *entry)
{
// whatever
}
virtual int getIPentryindex (void)
{
// whatever
}
};
Have you tried that? You can access the member variables defined in bcQueue
from cQueue (especially since there are public). Seems perfectly good to me,
does everything you want as far as I can tell.
As I said before the correct way to post question like yours is to post
COMPLETE COMPILABLE CODE. Then there is no room for misunderstanding. You
post some code, say what it does and what you want it to do. Then I put it
in might compiler and tell you why not. Surely you can think of a couple of
toy classes with a single method that illustrates the difficulty you are
having. Put them in a complete program, post it, and you'll get your answer
in hours if not minutes.
john