printf and custom class

后端 未结 4 1734
情深已故
情深已故 2020-12-21 16:31

I have my own class that represents a custom string class. I\'m using VS2012RC. I have overloaded some operators of my class CustomString.

Here\'s some code:

<
4条回答
  •  暖寄归人
    2020-12-21 16:59

    You have to use printf("%s\n", str.c_str());. %s expects a char array and you gave it a CustomString object which is something different. You have to get char array from the string by calling c_str() function.

提交回复
热议问题