-3

what happen when a class template instantiate . i.e i hv a class template and i have created class for int and class for float, so what will happen at compile time( compiler will create 2 seprate class for int and float) or not? eg :

template <typename T>
class A
{
    public:
        void foo(T t)
        {
            //...
        };
};

int main()
{

   A<int> a; 
    A<float> b;

}
Rakete1111
  • 47,013
  • 16
  • 123
  • 162

1 Answers1

-1

Yes, the compiler will create two new classes on-the-fly - one for int and one for float.

PhilMasteG
  • 3,095
  • 1
  • 20
  • 27