To perform string concatination & string comparison using operator overloading

Write a C++ program that overloads the + operator and relational operators (suitable) to perform the following operations:

  1. Concatenation of two strings.

2. Comparison of two strings.

 

 

Program to check whether the entered string is a substring of the main string or not.

Write a program that takes two input strings S1 and S2 and finds if S2 is a substring of S1 or not. If S2 is a substring of S1, the program should print the index at S1 at which there is a match. If S2 is not a substring of S1, the program should print -1. If S2 appears in S1 multiple times, print the first index in S1 at which the match occurred.

 

Code:

 

Create a class Rational Number (fractions) with mentioned capabilities

To create a class Rational Number (fractions) with the following capabilities:

  1. a) Create a constructor that prevents a 0 denominator in a fraction, reduces or simplifies fractions that are not in reduced form and avoids negative denominators.
  2. b) Overload the addition, subtraction, multiplication and division operators for this class.

c) Overload the relational and equality operators for this class.

 

 

Code: