please sir i want to comments of every code what i do in eachline . in this way
ID: 3608384 • Letter: P
Question
please sir i want to comments of every code what i do in eachline . in this way i good understand this programme. thanks sri.......... 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(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<" Enter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
please sir i want to comments of every code what i do in eachline . in this way i good understand this programme. thanks sri.......... 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(s1);
}
};
template <class myType>
myType add(myType a, myType b) {
myType res;
res = a+b;
return res;
}
int main()
{
int i1,i2;
float f1,f2;
string s1,s2;
cout<<"Enter Integer values:";
cin>>i1>>i2;
cout<<"Sum is :"<<add(i1,i2)<<endl;
cout<<" Enter float values:";
cin>>f1>>f2;
cout<<"Sum is :"<<add(f1,f2)<<endl;
cout<<"Enter two strings";
cin>>s1>>s2;
String str1(s1);
String str2(s2);
String str = add(s1,s2);
cout<<"sum is ";str.print();
cout<<endl;system("pause");
}
Explanation / Answer
x.x
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.