Page 170 - DCAP404 _Object Oriented Programming
P. 170
Unit 8: Type Conversion
public: Notes
stock20
{
code=0;val=0;
}
stock2(int x,float y)
{
code=x;val=y;
}
void disp()
{
cout<< “code” <<code <<“\n”;
cout<<“Total Value `” <<val <<“\n”;
}
stock2(stockl p)
{
code=p.getcode();
val=p.getitem() * p.getprice();
}
};
void main()
{
stock1 i1(101, 10,125.0);
stock2 i2; .
float tot_val;
tot_val=i1 ;
i2=i1 ;
cout<<“ Stock Details-stockl-type” <<“\n”;
i1.disp();
cout<< “ Stock value” << “\n”;
cout<< tot_val<< “\n”;
cout<< “ Stock Details-stock2-type” << “\n”;
i2.disp();
getch();
}
LOVELY PROFESSIONAL UNIVERSITY 163