Write a program for Private member function

/* Private member function  */
#include<iostream>
using namespace std;

class Sample
{
    int a,b;

    void accept()
    {
        cout<<"\n\n Enter any two number: ";
        cin>>a>>b;
    }


    public:

            void display()
            {
                accept();
                cout<<"\n A: "<<a<<"\n B: "<<b;
            }
};


int main()
{
    Sample s;

    s.display();

    return 0;
}

Previous
Next Post »