answersLogoWhite

0

The plus operator between string constants allows string concatination:

string a = "Hello, ";

string b = "World!";

string c = a + b;

The output of c would be: "Hello, World!".

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What can you do to an int that you cannot do to a string in C plus plus?

You can perform arithmetic with it. int x {42}; x *= 2; // ok std::string s {"Hello"}; s *= 2; // error: std::string::operator*= (int) is undefined


What is operand difference between operand and operator?

Simply defining, in an expression like A+B A is an Operand B is an Operand Plus is the Operator in between


Write a c plus plus program to use plus operator to display the sum of 2 numbers and concatenation of two strings by using operator overloading?

There is no need to overload the plus operator to achieve this. It is already overloaded with this functionality. #include<iostream> #include<string> int main() { int x=40; int y=2; int z=x+y; std::cout<<x<<" + "<<y<<" = "<<z<<std::endl; std::string s1="Hello "; std::string s2="world!"; std::string s3=s1+s2; std::cout<<"""<<s1.c_str()<<"" + ""<<s2.c_str()<<"" = ""<<s3.c_str()<<"""<<std::endl; return(0); }


What procedure or operator allows you to extract a single character from a string in c plus plus?

Use the array index operator. Strings are just arrays of characters so use the zero-based index of the character you are interested in. Alternatively, use pointer arithmetic to achieve the same thing. Note that the string's name is a reference to the start of the character array.


What is the difference between a C plus plus string and a C-style string?

A std::string is an object that encapsulates an array of type char whereas a C-style string is a primitive array with no members. A std::string is guaranteed to be null-terminated but a C-style string is not.


C plus plus program for overloading operator?

#include<iostream> #include<string> // a simple class class my_class { private: std::string m_caption; public: // default constructor my_class (std::string caption): m_caption (caption) {} // read-only accessor const std::string& get_caption() const { return m_caption; } }; // output stream insertion operator overload std::ostream& operator<< (std::ostream& os, const my_class& obj) { os << obj.get_caption(); return os; } int main() { // call default constructor my_class object1 ("This is the caption for object1"); // exercise output stream insertion operator overload std::cout << object1 << std::endl; }


What is the operator is used to allocate the memory in c plus plus?

calloc operator,malloc operator


What is the answer for 5 plus 3 plus 9 8 plus?

It is not possible to answer the question since there is no visible operator between 9 and 8.


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++


What is 73 9?

Impossible to answer without the missing operator between the 73 and the 9. Please resubmit with the operator as a word, eg "What is 73 plus 9"?


How do you use string operators in qbasic?

In QBASIC, string operators allow you to manipulate and combine strings. The primary operator is the concatenation operator, which is the semicolon (;) or the plus sign (+). For example, you can concatenate two strings like this: result$ = "Hello" + " World", resulting in result$ containing "Hello World". You can also use the LEN function to get the length of a string and the MID$, LEFT$, and RIGHT$ functions for extracting parts of strings.


What is the difference between literals and identifiers in C plus plus?

An identifier is a sequence of characters used to denote one of the following:Object or variable nameClass, structure, or union nameEnumerated type nameMember of a class, structure, union, or enumerationFunction or class-member functiontypedef nameLabel nameMacro nameLiterals (C++)Invariant program elements are called "literals" or "constants." The terms "literal" and "constant" are used interchangeably here. Literals fall into four major categories: integer, character, floating-point, and string literals.A literal may be any of the following:integer-constant character-constant floating-constant string-literal