When compiling the below I get the following error:
no match for 'operator<<' in 'log << std::endl' main.cpp
Why can't I use std::endl in my class?
no match for 'operator<<' in 'log << std::endl' main.cpp
Why can't I use std::endl in my class?
Code:
#include <iostream>
class Logger {
public:
template <typename T>
Logger& operator << (const T &t)
{
// do sth with t
std::cout << t;
return *this;
}
};
int main()
{
Logger log;
log << "Hello " << 10 << 20; // ok
log << std::endl; // fault here
}
Comment