fork download
  1. #include <iostream>
  2. using namespace std;
  3. class Mathematics
  4. {
  5. int x,y;
  6. public:
  7. void input()
  8. {
  9. cout<<"Input two integers\n";
  10. cin>>x>>y;
  11. }
  12. void add()
  13. {
  14. cout<<"Result:"<<x+y;
  15. }
  16. };
  17. int main()
  18. {
  19. Mathematics m;// Creating an object of the class
  20. m.input();
  21. m.add();
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5432KB
stdin
3
4
stdout
Input two integers
Result:7