0

Recently i got stuck in the templates , i passed a dummy argument in the template but this isn't working and gives compilation error here is my code..

#include <iostream>
using namespace std;
template<typename T>
class A{
    private:
        T b;
    public:
        A()
        {
            cout<<"1st is executing "<<endl;
        }
};
template<typename T,int>
class A{
    private:
        T b;
    public:
        A(){
            cout<<"2nd is executing "<<endl;
        }
};
int main(){
    A<string> a;
    A<string,100> b;
}

In my point of view it should work fine but it gives re declaration error and I dn't know why .....plz Help THANKS

1 Answers1

0

I'm not completely sure, but I think its template <typename T = int>

Leo Lindhorst
  • 232
  • 1
  • 8
  • that is default argument which is replaced by data type i-e int or char but in my case it will be replaced by const values like 10 if it is int .... – Mohsin Mushtaq Jun 04 '15 at 14:13