HOME

Sunday, November 29, 2015

OBJECT AS FUNCTION ARGUMENT

#include<iostream>
using namespace std;
class sample
{
    int minute,hour, second;
public:
    void getdata()
    {
        cout<<"ENTER TIME IN MINUTE"<<endl;
        cin>>minute;
    }
    void display(sample s1, sample s2)
    {
        minute=s1.minute+s2.minute;
        hour=minute/60;
        minute=minute%60;
        cout<<"total duration is "<<hour<<" hour "<<minute<<" minute. "<<endl;
    }
};
int main()
{
    sample s1,s2,s3;
    s1.getdata();
    s2.getdata();
    s3.display(s1,s2);
return 0;
}

No comments:

Post a Comment