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.

I figured out the problem
Just replace endl() by:

inline basic_ostream<TCHAR>& __cdecl endl(basic_ostream<TCHAR>& _Ostr)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.