In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the object characteristics of C++ and the relevant knowledge of what friends are. The content is detailed and easy to understand, easy to operate, and has a certain reference value. I believe that you will gain something after reading this article on the object characteristics of C++ and what friends are. Let's take a look.
Object characteristic constructor and destructor
Object initialization and cleanup are also two very important security issues.
An object or variable has no initial state, and the consequences of its use are unknown.
Similarly, if an object or variable is not cleaned up in time, it will also cause some security problems.
Constructor: the main function is to assign values to the member properties of the object when creating the object. The constructor is called automatically by the compiler without manual call.
Destructor: the main function is that the system automatically calls before the object is destroyed and performs some cleaning work.
Constructor syntax: class name () {}
1. Constructor that does not return a value or write void
two。 The function name is the same as the class name
3. Constructors can have arguments, so overloading can occur
4. The program automatically invokes the construction when the object is called, without having to call it manually, and only once.
Destructor syntax: ~ class name () {}
1. Destructor with no return value and no void
two。 The function name is the same as the class name, preceded by a symbol ~
3. Destructors cannot have parameters, so overloading cannot occur
4. The program automatically invokes the destructor before calling the object, without having to call it manually, and only once.
# initialization and cleaning of includeusing namespace std;// objects / / 1. The constructor implements the initialization operation class Person {public: / / 1 constructor / / No return value, no need to write void / / the function name is the same as the class name / / the constructor can have arguments, and when overloading / / creates an object, the constructor will call automatically and only call Person () {cout once
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.