/ Published in: C++
basic usage of nesting
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> //Vamsi // Nesting of member functions using namespace std; class comparing { int m,n; public: void input(void); void display(void); int larger(void); }; void comparing :: input(void) { cout << "Enter the two numbers to be compared \n"; cin >> m >> n; } void comparing :: display(void) { cout << "The larger number among the entered values is :" << larger() << endl; } int comparing :: larger(void) { if (m >= n) { return (m); } else { return (n); } } int main () { comparing x; x.input(); x.display(); return 0; }
URL: http://vamsii.com