daily pastebin goal
49%
SHARE
TWEET

Final Question 2

Haval1 Jan 20th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include"stdafx.h"
  2. #include "string"
  3. #include <iostream>
  4. /*
  5. write a cpp program to input two int number in main , and print sum in constructor function
  6. */
  7. using namespace std;
  8. class add {
  9. private:
  10.     int x, y;
  11. public:
  12.     add(int a, int b) {
  13.         x = a;
  14.         y = b;
  15.         cout << "sum : " << x + y << endl;
  16.     }
  17. };
  18. int main()
  19. {
  20.     int a, b;
  21.     cout << "a : ";
  22.     cin >> a;
  23.     cout << "b : ";
  24.     cin >> b;
  25.     add ad(a, b);
  26.     return 0;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top