I have to write an extension of basic_stringstream class, and I'm facing some difficulties with endl() function.
Here is my code
class Logger: public basic_stringstream<TCHAR> {
public:
Logger();
};
inline Logger& __cdecl endl(Logger& _Ostr) {
// Original code in ostream
_Ostr.put(_T('\n'));
_Ostr.flush();
return (_Ostr);
}
int main() {
Logger test;
test << "a" << endl << "b" << endl;
std::cout << test.str() << endl;
}
However, the result is something like:
a0041B366b0041B3660041B366
The function is not executed but instead its address was inserted.
I don't know how to get around this problem. Can anyone help me on this?
Thank you in advance.