In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the structure and case analysis of C++". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "C++ structure and destructions of the case analysis" bar!
1. Constructor 1.1 what does the constructor look like
(1) the function name is the same as the class name
(2) No return value
(3) if you do not write a constructor, there is a default constructor in any class.
I default constructor is unparameterized
II when we write our own constructor, the default constructor does not exist
(4) the constructor is called when constructing the object.
(5) delete can be used to delete the default function.
(6) specify the default no-parameter constructor, which is specified in default.
(7) allow the constructor to call another constructor, just write the initialization parameter list.
(8) initialization parameter list: only the constructor has
I constructor name (parameter 1, parameter 2, …) Member 1 (parameter 1), member 2 (parameter 2), … {}
II avoids problems caused by the same formal parameter name and data member name
1.2 what is the constructor for?
(1) the constructor is used to construct the object.
(2) Constructors are more often used to initialize data members.
1.3 thinking
(1) Why not write a constructor to construct an object? Because there is a default no-parameter constructor, you can construct no-parameter objects
(2) what is the purpose of constructor overloading? In order to construct different-looking objects.
# include using namespace std;class MM {public: / / MM () = delete; delete the default constructor MM (string mmName, int mmAge) {name = mmName; age = mmAge; 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.