Computer Science, asked by yogirlmansi2661, 1 year ago

Write a program to concatenate two strings using operator overloading in c++

Answers

Answered by ggghh76
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