Operator Overload

#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
using namespace std;

int main ()
{
string s1;
string s2;
int n;
while(true)
{
cout<< "Choose option\n";
cout<< "1.Add\n2.Minus\n3.Quit\n";
cin >> n;
cin.ignore();
if(n == 1)
{
cout << "Input A: ";
getline(cin , s1);
cout<< "Input B: ";
getline(cin , s2);
string s = "";
int i,j;
for ( i = 0, j =0; i < s1.size() && j < s2.size(); i++, j++)
{
int result = 0;
if(s1[i] == ' ') result = result + s2[j];
else if(s2[j] == ' ') result = result + s1[i];
else result = s1[i] + s2[j];

while(result > 'z'){ result = result - 'z'; }


s = s+ (char)result;
}

while(i < s1.size()) { s = s + s1[i]; i++;}
while(j < s2.size()) { s = s + s2[j]; j++;}

s = s + '\n';
cout << s << endl;
}


else if(n == 2)
{
cout << "Input A: ";
getline(cin , s1);
cout<< "Input B: ";
getline(cin , s2);
string s = "";
int i,j;
for ( i = 0, j =0; i < s1.size() && j < s2.size(); i++, j++)
{
int result = 0;
//if(s1[i] == ' ') result = result + s2[j];
//else if(s2[j] == ' ') result = result + s1[i];
result = s1[i] - s2[j];
while(result < 'A') {result = result + 'A';}


s = s+ (char)result;
}

while(i < s1.size()) { s = s + s1[i]; i++;}
while(j < s2.size()) { s = s + s2[j]; j++;}

s = s + '\n';
cout << s << endl;

}

else if( n == 3) return 0;
}
return 0;

}

For this problem I am trying to add or subtract two strings using the ASCII table. The problem I am having is I am confused on how to incorporate operator overload. I know you need to use classes and possibly struct but confused on how and where to implement it.
Topic archived. No new replies allowed.