Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include "string"
- #include <iostream>
- /*
- write a cpp program to input two int number in main , and print sum in constructor function
- */
- using namespace std;
- class add {
- private:
- int x, y;
- public:
- add(int a, int b) {
- x = a;
- y = b;
- cout << "sum : " << x + y << endl;
- }
- };
- int main()
- {
- int a, b;
- cout << "a : ";
- cin >> a;
- cout << "b : ";
- cin >> b;
- add ad(a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement