#include "foo.h"
#include <iostream>
int main()
{
foo f;
bar b;
std::cout << f.encode(10) << '\n';
std::cout << f.encode(b) << '\n';
return 0;
}
#include "foo.h"
template <> int foo::encode<bar>(const bar& t) {
return 1;
}
#ifndef FOO_H
#define FOO_H
class bar {};
class foo {
public:
template <typename T> int encode(const T& t);
};
template <typename T> int foo::encode(const T& t) {
return 0;
}
template <> int foo::encode<bar>(const bar& t); // added const
#endif