#include <iostream>
#include <string>
//注意头文件:string 和 string.h 的区别;
using namespace std;
//成员函数的调用时机:
class Person1
{
public:
void showPerson1()
{
cout << "Person1的调用" << endl;
}
};
class Person2
{
public:
void showPerson2()
{
cout << "Person2的调用" << endl;
}
};
template<class T>
class myClass
{
public:
T obj;
void func1()
{
obj.showPerson1();
}
void func2()
{
obj.showPerson2();
}
};
void test01()
{
myClass<Person1> m;
m.func1();
//m.func2();
}
//m.func1()可以调用,m.func2()不可以调用;
//说明,成员函数一开始不会创建出来,而是在程序运行时创建的;
//提高效率;
int main()
{
test01();
return 0;
}