In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the encapsulation method of C++". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Encapsulation
C++ believes that everything is an object, and the object has its attributes and behavior.
The meaning of encapsulation:
Attribute and behavior as a whole to express things in life
Apply permission control to attributes and behaviors
Encapsulation meaning one:
When designing a class, properties and behaviors are written together to represent things
Syntax:
Class class name {access rights: attribute / behavior}
Attributes and behaviors as a whole # includeusing namespace std;// pi const double PI = 3.14 / designing a circle class to find the perimeter of the circle / / the formula for finding the perimeter of the circle: 2circle Pi * radius class Circle {/ / access rights / / common permissions public: / / attributes / / radius int masks r / / behavior / / get the perimeter of a circle double calculateZC () {return 2 * PI * m circle;}}; int main () {/ / create a concrete circle (object) through a circle class / / instantiate (the process of creating an object through a class) Circle C1 / / assign a value to the attributes of the circle object c1.m_r = 10; / / 2 * PI * m _ r = 62.8; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 278
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.