The difference between C + + classes and struct structs

Source: Internet
Author: User

C + + retains the struct of the language and expands it. In the C language, a struct can contain only data members and cannot contain member functions . In C + +, astruct is similar to class, and can contain both a data member and a member function.

In C + +, structs and classes are basically generic, except that if you use the Class keyword, the member variable or member function defined in the class is the private property by default, and the struct keyword is used. A member variable or member function defined in a struct is the public property by default.

In C + +, the C language of the struct keyword is not discarded, its significance lies in the C language Program developers have a sense of belonging, and can make the C + + compiler compatible with the previous development of the C language project.

The difference between C + + classes and struct structs

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.