In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article, "C++ object model and how to use this pointers", so the editor gave you a summary of the following contents, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this "C++ object model and how to use this pointers" article.
The three object-oriented features of C++ are encapsulation, inheritance and polymorphism.
C++ believes that everything is an object, and the object has its attributes and behavior.
For example:
People can be used as objects, with attributes such as name, age, height, weight. Behaviors include walking, running, jumping, eating, singing.
The car can also be used as an object, with properties such as tires, steering wheel, headlights. The behaviors include carrying people, playing music and playing air conditioners.
Objects with the same nature can be abstractly called classes. People belong to human beings and cars belong to cars.
C++ object model and this pointer 1 member variables and member functions are stored separately
In C++, member variables and member functions within a class are stored separately
Empty object occupies one byte
The C++ compiler allocates a byte of space to each empty object to distinguish where the empty object occupies memory.
Each empty object should also have a unique memory address.
Non-static member variables, on objects belonging to the class
Static member variables, on objects that do not belong to the class
Non-static member function, on an object that does not belong to the class
Static member function, on an object that does not belong to the class
Non-static member variables, on objects belonging to the class, why?
The empty object originally occupies 1 byte, but after adding the non-static member variable [int], it takes up 4 bytes.
Summary: only non-static member variables belong to the object of the class.
Class Person {public: Person () {mA = 0;} / / non-static member variables occupy object space int mA; / / static member variables do not occupy object space static int mB; / / functions do not occupy object space, and all functions share a function instance void func () {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: 0
*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.