In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the C++ class in the default member function how to use, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
In C++, for any class, we will be provided with four default member functions (if we do not show to declare)-constructor, destructor, copy constructor, assignment function. These functions are called automatically under certain circumstances, but they do not mean that they can perform specific functions or tasks as users expect. More often, we need to implement the functions of these functions ourselves.
A (); / / default constructor ~ A (); / / destructor A (const A &); / / default copy function A & operator = (const A & a); / / default assignment function 1, constructor
The constructor is a special member function with the same name as the class, which is automatically called by the compiler when the object is created through the class, ensuring that each data member has an appropriate initial value and is called only once in the object's life cycle. The function of the constructor is implemented by the implementer of the class, and the function body and function parameters are designed according to the actual situation. The constructor must have one or can have more than one.
Both the class Person {public: / / no-parameter constructor and the full default constructor are called default constructors, and there can only be one default constructor. / / Note: no-parameter constructors, all default constructors, and constructors that we did not write default generated by the compiler can all be considered default member functions. Person (string name = "classmate Feng", int age = 18) {_ name = name; _ age = age;} / / print message void Print () const {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.