There are two different classes with intersecting set of methods:
class A {
public:
int Value1() { return 100; }
char Value2() { return "a"; }
void actionA() { };
}
class B {
public:
int Value1() { return 200; }
char Value2() { return "b"; }
void actionB() { };
}
The common part of the classes interface can be described like this:
class GenericPart {
public:
virtual int Value1();
virtual char Value2();
}
Please note that classes A and B come from some library and therefore cannot be inherited from GenericPart.
There is a template function that works with objects implementing methods described in GenericPart:
template <typename T>
void function(T record) {
std::cout << record.Value1() << " " << record.Value2() << std::endl;
}
Is it possible to specialize this template function to make it receive only objects that match GenericPart?