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

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 15  |  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.  = with strings in C  
  2. string s = "hi";
  3. s += " " + "there!";
  4.        
  5. error: invalid operands of types ‘const char [2]’ and ‘const char [6]’ to binary ‘operator+’
  6.        
  7. std::string("foo") + "bar"
  8.        
  9. s += string(" ") + "there!";
  10.        
  11. s += " "  "there!";
  12.        
  13. 632 $ g++ foo.C
  14. foo.C: In function ‘int main()’:
  15. foo.C:5:16: error: invalid operands of types ‘const char [2]’ and ‘const char [7]’ to binary ‘operator+’
  16.        
  17. 636 $ cat foo.C
  18. #include <string>
  19. using std::string;
  20. int main(void){
  21.     string s = "hi";
  22.     s += string(" ") + string("there!");
  23.     return 0;
  24. }