-
Notifications
You must be signed in to change notification settings - Fork 5
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
Comments
Dear class Pair{ }; |
This is c++ program and some error will be occur.please correct the program. |
@msabir063 If there is some error, please send a PR with your corrected version. Will be happy to merge it. |
**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: }; Please correct the program according to the question. |
class Pair{ }; but here Expected symbols ['Pair::sum()', 'Pair::sum()'] to be defined. |
#include
|
Thank you
…On Sun, 24 Apr, 2022, 01:02 Aman, ***@***.***> wrote:
correct answer
// You should define Pair here:
// (Use as many lines as you need!)
// ...
// ...
#include <bits/stdc++.h>
// This main() function will help you test your work.
// Click Run to see what happens.
// When you're sure you're finished, click Submit for grading
// with our additional hidden tests.
struct 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;
}
—
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APZLLU6HBHKFQ3PXN7BMCSDVGRF3XANCNFSM4LUI7TBA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
class Pair{ |
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
The text was updated successfully, but these errors were encountered: