#include<iostream.h>
#include<conio.h>
class validity
{
private:
                int mfg,exp,yr;
public:
                void read()
                                {
                                cout<<"Enter Manufacturing Year of Product : ";
                                cin>>mfg;
                                cout<<"Enter Expiry Year of Product : ";
                                cin>>exp;
                                }
                void period(validity &obj)
                                {
                                yr=obj.exp-obj.mfg;
                                cout<<"The Valid Period of Product Is : "<<yr;
                                }
};
void main()
{
                validity v;
                clrscr();
                v.read();
                v.period(v);
                getch();
}

151.PNG

Advertisements