class in1 { int code,items; float price; public: in1(int a,int b,int c) { code=a; items=b; price=c; } void putdata() { cout<<"\nCODE: "<<code<<"\nITEMS: "<<items<<"\nVALUE: "<<price; } int getcode() { return code; } int getitems() { return items; } int getprice() { return price; } operator float () { return items*price; } };
class in2 { int code, item; float value, tol_val; public: in2() { code=0, value=0; } in2(int x,float y) { code=x, value=y; } void putdata() { cout<<"\nCODE: "<<code<<"\nITEMS: "<<items<<"\nVALUE: "<<price; cout<<endl<<endl<<"\nTotal Price is "<<tol_val; } in2(in1 p) { code=p.getcode(); item=p.getitems() value=p.getprice(); tol_val=p.getitems()*p.getprice(); } };
void main() { clrscr(); in1 s1(100,51,140.0); in2 d1;
d1=s1; //class type to class type ...
cout<<"\nPRODUCT DETAILS INVENT-1 TYPES:->"; s1.putdata(); cout<<"\nPRODUCT DETAILS INVENT-2 TYPES:->"; d1.putdata();
getch(); } |