Why isn\'t it possible to pass std::cout\'s address as template argument?
Or if it is possible then how?
Here is what I tried:
#include
This fixes your code, omit the parenthesis:
#include
template
class MyClass
{
public:
void disp(void) {
(*stream) << "hello";
}
};
int main(void)
{
MyClass<&std::cout> MyObj;
MyObj.disp();
return 0;
}
Live Demo
A more detailed explanation why can be found here:
Error with address of parenthesized member function