There's nothing to say. Program La ~~
# Include < Iostream >
# Include < Cstdlib >
Using STD: cout;
Using STD: Endl;
Class Cobject;
Typedef Const Cobject * Lpco;
Class Cobject
{
Private :
Int Length;
Int Width;
Int Lefttop_xpoint;
Int Lefttop_ypoint;
Public :
Cobject ( Int L, Int W, Int X, Int Y );
Operator Lpco () Const ;
Void Co_print (lpco PCO) Const ;
} ;
Cobject: cobject ( Int L, Int W, Int X, Int Y)
{
Length=L;
Width=W;
Lefttop_xpoint=X;
Lefttop_ypoint=Y;
}
Cobject :: Operator Lpco () Const
{
Return(Cobject*)(This);
}
Void Cobject: co_print (lpco PCO) Const
{
Cout < PCO -> Width < Endl
< PCO -> Length < Endl
< PCO -> Lefttop_xpoint < Endl
< PCO -> Lefttop_ypoint < Endl;
}
Int Main ()
{
Cobject Co (3,4,5,6);
CO. co_print (CO );
System ("Pause");
}
Flexibility is the same as that of C/C ++, and security risks are the same.
Compared with its flexibility, I think the use of automatic conversion from objects to pointers should be a last resort