Return to Snippet

Revision: 38562
at January 5, 2011 04:06 by vamsi


Initial Code
#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;
}

Initial URL
http://vamsii.com

Initial Description
basic usage of nesting

Initial Title
C++ Nesting of member functions

Initial Tags

                                

Initial Language
C++