[ create a new paste ] login | about

Link: http://codepad.org/eTgLG932    [ raw code | output | fork ]

valkrin - C++, pasted on Jun 29:
#include <iostream>
#include <cstdlib>
#include <string>

struct Bar
{
  std::string blah() { return "blah"; }
};

template <typename T>
struct Foo
{
public:
  std::string doX()
  {
    return m_getY(my_t);
  }

private:
  std::string m_getY(char* p_msg)
  {
    return std::string(p_msg);
  }

  std::string m_getY(T* p_msg)
  {
    return p_msg->blah();
  }

  T my_t;
};

int main(int, char**)
{
  Foo<char> x;
  Foo<Bar> y;
  std::cout << "x " << x.doX() << std::endl;
  return EXIT_SUCCESS;
}


Output:
1
2
3
4
t.cpp: In instantiation of 'Foo<char>':
t.cpp:36:   instantiated from here
Line 25: error: 'std::string Foo<T>::m_getY(T*) [with T = char]' cannot be overloaded
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: