Example

In this example, we have two functions named foo which overload each other. This can cause unexpected behavior.

template<class T> class MyClass {
   public:
      int foo(T type);
      int foo(int b);
};

Solution

The solution is to either write specialized functions, as the example below demonstrates, or to use specialized function templates which remove any ambiguity from the code.

template<class T> class MyClass {
   public:
      int fncType(T type);
      int fncInt(int b);
};