Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running code on ubuntu #1

Open
KotaibaMokadam opened this issue Mar 26, 2020 · 8 comments
Open

Running code on ubuntu #1

KotaibaMokadam opened this issue Mar 26, 2020 · 8 comments

Comments

@KotaibaMokadam
Copy link

Dear
Thanks for your efforts and sharing
However, the code does not work and I have tried many times to run it but it did not.
Can u clarify how to run or to see if there is a mistake in files after uploading
thanks in advance
Kotaiba Mokadam

@msabir063
Copy link

Dear
I want answer of this question.
Create a class called Pair that has two public integer member variables named "a" and "b", and a public member function named sum() that has no arguments but adds the two member variables together and returns their sum.

class Pair{
public:
float Pair;
int a,b,sum();

};
int main()
{
Pair p;
p.a = 100;
p.b = 200;
if (p.a + p.b == p.sum()) {
std::cout << "Success!" << std::endl;
} else {
std::cout << "p.sum() returns " << p.sum() << " instead of " << (p.a + p.b) << std::endl;
}
return 0;
}

@msabir063
Copy link

Dear
Thanks for your efforts and sharing
However, the code does not work and I have tried many times to run it but it did not.
Can u clarify how to run or to see if there is a mistake in files after uploading
thanks in advance
Kotaiba Mokadam

This is c++ program and some error will be occur.please correct the program.

@JanaSabuj
Copy link
Owner

@msabir063 If there is some error, please send a PR with your corrected version. Will be happy to merge it.

@msabir063
Copy link

**QUESTION:**Create a class called Pair that has two public integer member variables named "a" and "b", and a public member function named sum() that has no arguments but adds the two member variables together and returns their sum.

PROGRAM:
class Pair{
public:
float Pair;
int a,b,sum();

};
int main()
{
Pair p;
p.a = 100;
p.b = 200;
if (p.a + p.b == p.sum()) {
std::cout << "Success!" << std::endl;
} else {
std::cout << "p.sum() returns " << p.sum() << " instead of " << (p.a + p.b) << std::endl;
}
return 0;
}

Please correct the program according to the question.

@youtarun
Copy link

youtarun commented Nov 20, 2021

class Pair{
public:
float Pair;
int a,b,sum();

};
int main()
{
Pair p;
p.a = 100;
p.b = 200;
if (p.a + p.b == p.sum()) {
std::cout << "Success!" << std::endl;
} else {
std::cout << "p.sum() returns " << p.sum() << " instead of " << (p.a + p.b) << std::endl;
}
return 0;
}

but here Expected symbols ['Pair::sum()', 'Pair::sum()'] to be defined.
please tell me your take on this.

@Yuvraj3905
Copy link

Yuvraj3905 commented Jan 5, 2022

Create a class called Pair that has two public integer member variables named "a" and "b", and a public member function named sum() that has no arguments but adds the two member variables together and returns their sum.
HERE IS THE ANSWER @msabir063 @JanaSabuj @youtarun

#include
using namespace std;

class Pair{ public: float Pair; int a,b;
int sum(){
return (a+b);
}

}; int main() { Pair p; p.a = 100; p.b = 200; if (p.a + p.b == p.sum()) { std::cout << "Success!" << std::endl; } else { std::cout << "p.sum() returns " << p.sum() << " instead of " << (p.a + p.b) << std::endl; } return 0; }

@msabir063
Copy link

msabir063 commented Apr 24, 2022 via email

@riparuk
Copy link

riparuk commented Aug 12, 2022

class Pair{
public:
int a;
int b;
int sum(){
return a+b;
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants