0

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.

Edited by paddy8788: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by paddy8788
0

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

inline basic_ostream<TCHAR>& __cdecl endl(basic_ostream<TCHAR>& _Ostr)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.