Write a program to concatenate two strings using operator overloading in c++
Answers
Answered by
0
nput: str1 = "hello", str2 = "world"
Output: helloworld
Input: str1 = "Geeks", str2 = "World"
Output: GeeksWorld
To concatenate two strings using unary operator overloading. Declare a class with two string variables.
Create an instance of the class and call the Parametrized constructor of the class to initialize those two string variables with the input strings from the main function.
Overload the unary operator + to concatenate these two string variables for an instance of the class.
Finally, call the operator function and concatenate two class variables.
Similar questions
Math,
7 months ago
Chemistry,
7 months ago
Biology,
7 months ago
Computer Science,
1 year ago
English,
1 year ago