G++ 3.4/Linux stringstream question...

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Earned a small fee
Earned a small fee
Posts: 10
Joined: Wed Jun 15, 2005 5:44 pm

G++ 3.4/Linux stringstream question...

Post by alaricljs » Tue Jun 28, 2005 11:10 pm

This isn't directly related to wxWidgets, so please point to a better forum if you can, this is the only one I'm on in regards to C++.

I've got a class that includes a ostringstream in it's public section:

std::ostringstream OutStream;

When I go to compile I get these errors:

Code: Select all

g++-3.4 -I./includes -c -Wall -g -o main.o main.cpp
main.cpp: In copy constructor `std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)':
/usr/include/c++/3.4/bits/ios_base.h:781: error: `std::ios_base::ios_base(const std::ios_base&)' is private
main.cpp:38: error: within this context
main.cpp: In copy constructor `std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::basic_stringbuf(const std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >&)':
/usr/include/c++/3.4/streambuf:769: error: `std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]' is private
main.cpp:38: error: within this context
main.cpp: In function `int main()':
main.cpp:38: error:   initializing temporary from result of `MySock::MySock(const sockbuf::sockdesc&)'
make: *** [main.o] Error 1
I understand what they're saying more or less. I just don't know why or the best way to fix it. I want an ostringstream in my class, how can I get it to work?

Thanks tons,
wxWidgets 2.6.1
WinXP SP2 (+all)

Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore

Post by lowjoel » Sat Jul 23, 2005 2:17 pm

did u try initializing the stringstream? i.e.

Code: Select all

class myClass
std::stringstream stream;

std::string mystr;
myClass::myClass() : stream(str)
maybe it will work that way.


Post Reply