14 14 .
¿.E(M5D-DJJ)(EEI6-#)1:2*>E9-:88:>T9#@+J$>..?.=R:IPR>SBMF+NG2N&3F:J7T$@N=5JQ:
Operator overloading for a templated class
I have a templated class foo that looks like this:
class foo{
public:
template
void bar(arg x);
};
I have another class bar which looks like this:
class bar{
public:
template
void bar(foo* f, arg x);
};
Now, I want to overload the bar method of foo so that it can be used to call the foo::bar method with any type of arg.
Here is my attempt:
#include
template
class foo{
public:
template
void bar(arg x);
};
class bar{
public:
template
void bar(foo* f, arg x);
};
template
void foo::bar(arg x){
std::cout a;
bar b;
a.bar(10);
b.bar(a, 10);
return 0;
}
Unfortunately, I get an error that says "no member named bar" on b.bar.
I would like to have a single method that can handle any type of arg.
How can I do be359ba680
Related links:
Commentaires