Modify pointed object method behaviour

A

Arkaitz Jimenez

Hi all,

I think this is mostly impossible, but just want to be sure.
Say that I have this 2 untouchable things:
void my_func(MyBase *baseptr){
base_ptr->one();
base_ptr->two();
}
class MyBase{
void one(){implemented}
void two(){implemented}
};

And now I want to test if my_func works ok but I can't use a MyBase
object, one and two implementations are too heavy, I could use
anything that my_func accepts, it'd accept pointers to derived.

So, as far as I know any implementation would hardcode base_ptr->one
to the MyBase::eek:ne and base_ptr->two MyBase::two because they're not
even virtual and that doesn't let me any room to play, inheritance,
etc....
There's nothing I could do with RTTI that would do the trick without
modifying MyBase or my_func.
Am I correct?

Thanks

Arkaitz
 
J

James Kanze

I think this is mostly impossible, but just want to be sure.
Say that I have this 2 untouchable things:
void my_func(MyBase *baseptr){
base_ptr->one();
base_ptr->two();}
class MyBase{
void one(){implemented}
void two(){implemented}
};
And now I want to test if my_func works ok but I can't use a
MyBase object, one and two implementations are too heavy, I
could use anything that my_func accepts, it'd accept pointers
to derived.
So, as far as I know any implementation would hardcode
base_ptr->one to the MyBase::eek:ne and base_ptr->two MyBase::two
because they're not even virtual and that doesn't let me any
room to play, inheritance, etc....
There's nothing I could do with RTTI that would do the trick without
modifying MyBase or my_func.
Am I correct?

Create a stub implementation of MyBase, and link to it, rather
than to the full implementation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top