Here is my simplified data structure:
Object1.h
template <class T>
class Object1
{
private:
T a1;
T a2;
public:
T getA1() {return a1;}
};
Object2.h
template <class T>
class Object2: public Object1 <T>
{
private:
T b1;
T b2;
public:
T getB1() {return b1;}
}
Is there any way to get the type T from an object in the following function:
Functions.h
template <class Object>
void (Object *o1, Object *o2)
{
T = o1->getA1(); // Is it possible to get T from object o1?
// ...
}
Or must we give additional information about data types of both objects, like this:
template <class T, class Object>
void (Object *o1, Object *o2)
{
T = o1->getA1();
// ...
}
Add a
usingortypedefstatement, like this: