#include <iostream>
using namespace std;
template<class T>
class A
{
private:
T m_value;
public:
A(const T & input)
: m_value(input)
{}
template<typename TT> // TT는 doSomething 함수 안에서만 템플릿 파라미터로 작용
void doSomething(const TT & input)
{
cout << typeid(T).name() << " " << typeid(TT).name() << "\n";
cout << (TT)m_value << "\n";
}
void print()
{
cout << m_value << "\n";
}
};
int main()
{
A<int> a_int(123);
a_int.print();
a_int.doSomething<float>();
A<char> a_char('A');
a_char.print();
a_char.doSomething(int()); // A가 int 타입으로 출력
// or a_char.doSomething<int>();
return 0;
}