目录

operator+=

描述 (Description)

它通过在其当前值的末尾附加附加字符来扩展字符串。

声明 (Declaration)

以下是std :: string :: operator + =的声明

string& operator+= (const string& str);

C++11

string& operator+= (const string& str);

参数 (Parameters)

  • str - 它是一个字符串对象。

  • c - 这是一个角色对象。

返回值 (Return Value)

它返回* this。

异常 (Exceptions)

如果抛出异常,则字符串中没有变化。

例子 (Example)

在下面的例子中,std :: string :: operator + =。

#include <iostream>
#include <string>
int main () {
   std::string name ("Sairamkrishna");
   std::string family ("Mammahe");
   name += " Prasad. ";
   name += family;
   name += '\n';
   std::cout << name;
   return 0;
}
Sairamkrishna Prasad. Mammahe
↑回到顶部↑
WIKI教程 @2018