Error C2079 Ostringstream
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the stringstream to string workings and policies of this site About Us Learn more about Stack
C++ Stringstream
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Istringstream C++
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join
Ostringstream
them; it only takes a minute: Sign up C++: Can't use std::wstringstream up vote 1 down vote favorite 4 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? c++ compiler-errors c2079 share|improve stringstream example this question edited Jun 23 '10 at 4:50 bdonlan 133k18185269 asked Jun 7 '10 at 17:02 Nick Heiner 35.9k113366616 2 Did you #include ? –Amardeep AC9MF Jun 7 '10 at 17:07 add a comment| 3 Answers 3 active oldest votes up vote 9 down vote accepted Include header share|improve this answer answered Jun 7 '10 at 17:08 Artyom 21.4k1590181 add a comment| up vote 2 down vote 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. share|improve this answer answered Jun 7 '10 at 17:04 bshields 3,203914 3 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 Jun 7 '10 at 17:24 add a comment| up vote 0 down vote 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++ pr
{ std::ostringstream oss; } I am simply trying to emulate http://en.allexperts.com/q/C-1040/2008/1/Converting-double-string.htm Yet I got an error Error 1 error C2079: 'oss' uses undefined class 'std::basic_ostringstream<_Elem,_Traits,_Alloc>' \\work\c\business\fromwork\currentprojects\program\library\cpp\locationBasedAds\platformDependent.cpp 38 locationBasedAds Jan http://stackoverflow.com/questions/2991521/c-cant-use-stdwstringstream 11, 2011 at 4:36pm UTC declan (87) Are you doing #include ? I'm not sure but I think that's what needs to be included... Jan 11, 2011 at 4:46pm UTC http://www.cplusplus.com/forum/general/34274/ teguh123 (49) I included iostream Where do I can find that ostringstream requires sstream? Jan 11, 2011 at 5:42pm UTC Seraphimsan (954) well, I dont know where you can find that it requires it, but it does. iostream doesnt hold the stringstream classes. sstream does. Last edited on Jan 11, 2011 at 5:42pm UTC Topic archived. No new replies allowed. C++ Information Tutorials Reference Articles Forum Forum BeginnersWindows ProgrammingUNIX/Linux ProgrammingGeneral C++ ProgrammingLoungeJobs Home page | Privacy policy© cplusplus.com, 2000-2016 - All rights reserved - v3.1Spotted an error? contact us
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine https://social.msdn.microsoft.com/Forums/en-US/c4b9dc9a-0592-4a20-8876-4c75154c700c/convert-uses-undefined-class-stdbasicstringstream?forum=Vsexpressvc Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples https://bytes.com/topic/c/answers/137192-simplify We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home error c2079 Browse forums users FAQ Search related threads Remove From My Forums Answered by: 'convert' uses undefined class 'std::basic_stringstream' Archived Forums V > Visual C++ Express Edition Question 0 Sign in to vote #include "stdafx.h" #include #include #include #include #include #include error c2079 ostringstream #include #include #include #include #include #include #include string drive_ID ; for (int i= 65; i<=90;i++ ) { stringstream convert; convert << i; //*error C2079: 'convert' uses undefined class 'std::basic_stringstream<_Elem,_Traits,_Alloc>' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits, 1> _Alloc=std::allocator 1> ] warning C4552: '<<' : operator has no effect; expected operator with side-effect */ drive_ID = convert.str(); //error C2228: left of '.str' must have class/struct/union drive_ID = i + ":\\" ; drive_type = GetDriveType(drive_ID); if (drive_type != 3) continue; filename = drive_ID + ":\\Program Files\\JuniorT\\254.txt" ; exist = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); CloseHandle(exist); i have encount a compile error which want sb to helphow to amend~ thanks Wednesday, June 17, 2009 3:40 PM Answers 2 S
tips & solutions from a community of 418,506 IT Pros & Developers. It's quick & easy. Simplify this ? P: n/a Flzw Alright, here is a simple function I coded, won't be hard understanding what it does, and YES, I know, you will probably tell me it's awful code, I would like to know how to write it better, maybe using stringstream ? here it is : std::string IntToDiskSpace( int size) { if (size < 1024) return IntToStr( size ) + " Bytes"; else if (size < 1048576) return IntToStr( size / 1024) + "KB"; else if (size < 1073741824) { char* temp = new char[64]; sprintf( temp, "%2f", size / 1048576); string result = temp; result += " MB"; delete temp; return result; } else { char* temp = new char[64]; sprintf( temp, "%2f", size / 1073741824); string result = temp; result += " GB"; delete temp; return result; } } Jul 22 '05 #1 Post Reply Share this Question 29 Replies P: n/a Mike Wahler "Flzw" wrote in message news:41**********************@news.wanadoo.fr... Alright, here is a simple function I coded, won't be hard understanding what it does, No, we cannot know what it does, since it calls a function whose definition you don't show. and YES, I know, you will probably tell me it's awful code, Well, it's incomplete code. It won't compile. If you want folks to assess it, it's much better to post something compilable if at all possible. I would like to know how to write it better, maybe using stringstream ? here it is : I suggest you tell us, in English, what you want it to do. And yes, I'd get rid of the e.g. 'sprintf()'s as there are safer, more robust ways to generate strings. I'd also dump the unnecessary dynamic allocations. -Mike Jul 22 '05 #2 P: n/a Flzw Allright, as Mike pointed out, there was not the code for another function I made but that was irrelevant in the questions I had but yes I agree that was not necessarily obvious, so let's reduce the code to this : std::string IntToDiskSpace( int size) { if (size < 1073741824) { char* temp = new char[64]; sprintf( temp, "%2f", size / 1048576); string result = temp; result += " MB"; delete temp; return result; } else { char* temp = new char[64]; sprintf( temp, "%2f", size / 1073741824); string result = temp; result += " GB"; delete temp; return result; } } I know I shouldn't use sprintf (thus the "unecessary dynamic allocations" but I'm unsure on how to dit, I guess stringstream or stringbuf could help there but these are quite obscure for me... Jul 22 '05 #3 P: n/a