Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C   Concatenation Oops
  2. string LongString = "Long String";
  3.  
  4. char firstChar = LongString.at(0);
  5.        
  6. void MethodA(string str)
  7. {    
  8. //some code    
  9. cout << str;    
  10. //some more code }
  11.        
  12. MethodA("1. "+ firstChar );
  13.        
  14. MethodA(std::string() + "1. " + firstChar);
  15.        
  16. MethodA(std::string("1. ")+ firstChar );
  17.        
  18. MethodA("1. "+ firstChar );  //your code
  19.        
  20. MethodA(string("1. ")+ firstChar ); //my code