Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template <class T>
- class MyPair {
- private:
- T first, second;
- public:
- MyPair() {}
- ~MyPair() {}
- bool isGreaterThan() {
- return (first > second) ? true : false;
- }
- void read() {
- cin >> first >> second;
- }
- };
- int main() {
- int choice;
- cout << "1 - int, 2 - float" << endl << "Enter Choice: ";
- cin >> choice;
- if(choice == 1) {
- MyPair<int> mp;
- mp.read();
- if(mp.isGreaterThan()) cout << "First is Greater" << endl;
- else cout << "First is Not Greater" << endl;
- }
- else {
- MyPair<float> mp;
- mp.read();
- if(mp.isGreaterThan()) cout << "First is Greater" << endl;
- else cout << "First is Not Greater" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement