Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » how to input an int into std::string? and an exception question
icon5.gif  how to input an int into std::string? and an exception question [message #13362] Thu, 03 January 2008 04:10 Go to previous message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
iota is good, but that is for char *.
i used std::stringstream, which accepts int well, but when i convered it into std::string and threw it, my program crashed.
std::stringstream msg;
msg << "failed to bind to " << localSocket->ip() << ":" << localSocket->port()/* this is an int */;
throw std::string(msg.str()); //or simply  throw msg.str();

...
catch (std::string err) ...

& i want standard C++ method, not String or alike.
another question is why my functions cannot throw an exception by default
child() {... throw std::string("error"); }
  dad() {... child(); ...}/*crashes*/
  mum() {... try { child(); }/*this works*/
    catch (std::string err) { throw err; }}
grand() {... try { dad()/* or mum()*/; }
  catch (std::string err) {....}}

today i just ran mum() again, and it crashed, too... (since i had been Debuggin, i could locate the last sentence is throw)

[Updated on: Thu, 17 January 2008 07:05]

Report message to a moderator

 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: Proposed change for TabCtrl: Color of text...
Next Topic: How can Layout be used for non-TopWindow special widget?
Goto Forum:
  


Current Time: Mon Apr 29 10:03:54 CEST 2024

Total time taken to generate the page: 0.02647 seconds