I have this code:
struct C
{
int d1;
int d2;
};
struct A
{
void write(C data)
{
}
};
struct B
{
void use(C data)
{
}
};
Now I want to define a new class that uses A
or B
, and will call their method write
and use
. Something like that:
template <class T>
struct D
{
T t;
D(T myT) { t=myT; }
void myFunct(C data)
{
}
};
As you can see if the two classes have similar method names, it would be easy to implement D
, but since A
they B
have different methods, then I need to tell the compiler which method it should use. How can i do this?
I do not want to change A
either B
, and I also do not want to subclass A
and B
to create a method with the same name.
I need a way to tell the compiler which method to use as part of the template, is this possible?