HI
I have written this code but there is errors in it and not going to be compiled please help me out after removing errors.. i need on urgent bases becoz i have only one day to submit ...
this is the code
=====================
#include<iostream>
#include <string>
using std::string;
class String
{
public:
string str;
String(string s)
{
str=s;
}
void print(){
cout<<str;
}
String operator+(String obj)
{
string s1=str + obj.str;
return String(string1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int value1,value2;
float fvalue1,fvalue2;
string string1,string2;
cout<<"\nPlease Enter two integer values to be added";
cout<<"Please Enter First value:";
cin>>value1;
cout<<"Please Enter Second value:";
cin>>value2;
cout<<"\nEnter two Float values to be added";
cout<<"Please Enter First value:";
cin>>fvalue1;
cout<<"Please Enter Second value:";
cin>>fvalue++2;
cout<<"\nPlease Enter two Strings values to be added";
cout<<"Please Enter First String:";
cin>>string1;
cout<<"Please Enter Second value:";
cin>>string2;
cout<<"Sum of values of type int:"<<add(value1,value2)<<endl;
cout<<"Sum of values of type float:"<<add(fvalue1,fvalue2)<<endl;
String str1(string1);
String str2(string2);
String str = add(string1,string2);
cout<<"Sum of values of type String:";str.print();
cout<<endl;
system("pause");