Skip to content

Commit

Permalink
Add Week_1_Orientation_Write_a_cpp_program
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchiang-tw committed Nov 27, 2019
1 parent db1b16f commit e88837a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <iostream>
using namespace std;



// You should define Pair here:
// (Use as many lines as you need!)
// ...
// ...
class Pair{
public:
int a;
int b;

int sum()
{
return (a+b);
}

};
//End of definition of class Pair



// 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.
int main() {
Pair p;
p.a = 100;
p.b = 200;

// expected output
// Success!
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;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit e88837a

Please sign in to comment.