views:

283

answers:

3

For some reason, my project won't compile when I try to create a wstringstream:

std::wstringstream stringstream;

This causes error C2079:

'stringstream' uses undefined class 'std::basic_stringstream<_Elem, _Traits, _Alloc> with [_Elem=wchar_t, _Traits=std::char_traits, _Alloc=std::allocator'

What am I doing wrong?

+2  A: 

I think your problem is the stringstream variable name. The compiler is recognizing it as a type. Try changing the variable name to something else as a test.

bshields
`std::wstringstream stringstream;` hints that the OP is not `using namespace std;` , so this probably isn't the issue. But +1 anyhow, because it's still bad.
Brian
+1  A: 

Include <sstream> header

Artyom
A: 

The compiler complains that wstringstream is undefined. Normally if unicode is enabled this call should be included when you include sstream. Right-click your VC++ project, set :-

Configuration Properties -- > General -- > Character Set --> "Use Unicode Character Set"

See if this works for you...

Abhay