Object and pointer

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.