I've the following code
class Person {
public:
string fname, lname;
string getName() {
return fname + " " + lname;
}
};
template<class T> class A {
...
};
int main() {
A<Person>* a = new A<Person>();
}
Since for template class A
, I have T
saved as Person. Is there any way I can use the methods and variable in the Person class? Like,
template<class T> class A {
public:
A() {
T* person = new T();
person->fname = "John";
person->lname = "Doe";
}
};
Is there some way something like this could be done?