There is the following simplified data structure:
Object1.h
template class Object1 { private: T a1; T a2; public: T g
Add a typedef :
template class Object1 { private: T a1; T a2; public: T getA1() {return a1;} typedef T type; }; template void foo(Object *o1, Object *o2) { typename Object::type x = o1.getA1(); ... }