Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBaneTrapper

Posted 15 February 2013 - 05:36 AM

Note how the standard library could allow such a conversion from std::string to const char *, but chooses not to. Conversion operators are hidden and can introduce subtle bugs. Providing an explicit str() method would be preferred.

That would be good enough.

What i don't know what i am looking for, in term of programing.

I cant find with Google a tutorial that would show how to make a "class int" with all functions it currently poses.

I really hate do make std::stringstream name.

then feed it int data.

then use it as .str()

then when i want to reuse it i need to clean it.

 

example

 

//I want
my_int a = 0;
a = unit.attack_power;
my_text.setText(a.str());
 
//I have
my_int a = 0;
a = unit.attack_power;
std::stringstream conv_attack_power;
conv_attack_power << a;
my_text.setText(conv_attack_power.str());

EDIT:: Note i don't want to replace the standard int i want to make a new class when i require this kind of usage.


#2BaneTrapper

Posted 15 February 2013 - 05:35 AM

Note how the standard library could allow such a conversion from std::string to const char *, but chooses not to. Conversion operators are hidden and can introduce subtle bugs. Providing an explicit str() method would be preferred.

That would be good enough.

What i don't know what i am looking for, in term of programing.

I cant find with Google a tutorial that would show how to make a "class int" with all functions it currently poses.

I really hate do make std::stringstream name.

then feed it int data.

then use it as .str()

then when i want to reuse it i need to clean it.

 

example

//I want
my_int a = 0;
a = unit.attack_power;
my_text.setText(a.str());
 
//I have
my_int a = 0;
a = unit.attack_power;
std::stringstream conv_attack_power;
conv_attack_power << a;
my_text.setText(conv_attack_power.str());

#1BaneTrapper

Posted 15 February 2013 - 05:21 AM

Note how the standard library could allow such a conversion from std::string to const char *, but chooses not to. Conversion operators are hidden and can introduce subtle bugs. Providing an explicit str() method would be preferred.

That would be good enough.

What i don't know what i am looking for, in term of programing.

I cant find with Google a tutorial that would show how to make a "class int" with all functions it currently poses.

I really hate do make std::stringstream name.

then feed it data.

then when i want to reuse it i need to clean it.


PARTNERS