Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class T>
- class Sum
- {
- public:
- T a, b;
- T sum(T a, T b)
- {
- T c;
- c = a + b;
- return c;
- }
- };
- int main()
- {
- Sum <int>a1;
- cout << "Sum of 2 integer data-types is: " << a1.sum(4, 7) << endl;
- Sum<float> a2;
- cout << "Sum of 2 float data-types is: " << a2.sum(3.6, 4.2) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement