F&A Diskussionen
can anyone plz explain me this program step by step?#include <iostream>
using namespace std;
class MyClass {
public:
int var;
MyClass() { }
MyClass(int a)
: var(a) { }
MyClass operator+(MyClass &obj) {
MyClass res;
res.var= this->var+obj.var;
return res;
}
};
int main() {
MyClass obj1(12), obj2(55);
MyClass res = obj1+obj2;
cout << res.var;
}I am not getting the part inside operator+
0 Stimmen
8 Antwortenhello guys? how are you. i am zeeshan ali from pakistan. i have been in touch with this app for a very long long time. i have found so many friends awesome.. and we do combine study over the internet. anyone of you is interested then join us on facebook by searching this number 03033951255
0 Stimmen
4 AntwortenWhen I enter two numbers the sum is displayed.. but when I input character as yes not y... Then it goes into an infinite loop... can anyone explain why?
int a,b;
char ch;
do
{
cout<<"Enter two numbers: ";
cin>>a>>b;
cout<<"The sum is "<<a+b
<<"\nDo you want to try again (y/n): ";
cin>>ch;
}while(ch=='Y'||ch=='y');
0 Stimmen
4 AntwortenCan anyone help me to code this
Write a method 'timesTable()' which accepts an integer value num from the keyboard and uses it to print 'times table' of itself in a structured format. Your output must include a header row. For example, if the user enters 5, your program's output should be:
5 Times Table
1 5 5
2 5 10
3 5 15
4 5 20
5 5 25
6 5 30
0 Stimmen
5 Antworten