S
Simon Elliott
--- foo.h ---
class foo
{
public:
virtual void DoStuff(void);
virtual ~foo();
};
--- bar.h ---
#include "foo.h"
class barublic foo
{
public:
virtual void DoStuff(void);
};
--- bloggs.cpp ---
#include "foo.h"
extern void Bloggs(foo* myFoo)
{
foo* localFoo = new foo(*myFoo);
localFoo->DoStuff();
delete localFoo;
}
--- main.cpp ---
#include "bar.h"
#include "bloggs.h"
int main(int argc, char* argv[])
{
bar myBar;
Bloggs (&myBar);
return 0;
}
In the code above, In the function "Bloggs", localFoo is a foo copy
constructed from the foo part of the bar argument I passed in.
Instead of this, I want to copy the complete bar argument and assign the
result to localFoo. Is there any way of doing this without bloggs.cpp
needing to #include "bar.h"? (I suppose I need something analogous to a
virtual copy constructor...)
class foo
{
public:
virtual void DoStuff(void);
virtual ~foo();
};
--- bar.h ---
#include "foo.h"
class barublic foo
{
public:
virtual void DoStuff(void);
};
--- bloggs.cpp ---
#include "foo.h"
extern void Bloggs(foo* myFoo)
{
foo* localFoo = new foo(*myFoo);
localFoo->DoStuff();
delete localFoo;
}
--- main.cpp ---
#include "bar.h"
#include "bloggs.h"
int main(int argc, char* argv[])
{
bar myBar;
Bloggs (&myBar);
return 0;
}
In the code above, In the function "Bloggs", localFoo is a foo copy
constructed from the foo part of the bar argument I passed in.
Instead of this, I want to copy the complete bar argument and assign the
result to localFoo. Is there any way of doing this without bloggs.cpp
needing to #include "bar.h"? (I suppose I need something analogous to a
virtual copy constructor...)