Suppose we have a class:
template <class Type> class A { public: void function1(float a, Type b); void function1(float a, float b); };
Now create an instance of the class as follows:
A<int> a;
Well, this class will have 2 overloaded functions with these parameters: (float a, int b); (float a, float b);
But when you instantiate the class as follows:
A<float> a;
You get a compilation error:
member function redeclared.
So, depending on the type of Type, I donβt want (or donβt want) the compiler to define a function, something like this:
template <class Type> class A { public: void function1(float a, Type b); #if Type != float void function1(float a, float b); #endif };
But of course, the syntax above does not work. Is it possible to perform such a task in C ++? If possible, provide an example.
c ++ function parameters templates
Vadim
source share