Keywords: constructors, shallow copy, deep copy, stack (stack), heap heap, assignment operatorSummary:In object-oriented programming, the mutual copying and assignment between objects is a frequent operation.If an object is initialized at the same
Priority level
Operator
Describe
Example
Binding nature
1
() [] -> . :: + + --
Array subscript access operator operator that accesses a member through a pointer to an object operator that accesses
In each class, there are constructors, destructors, assignment operators. These functions are the fundamental function of a class that controls the creation and initialization of objects, the cleanup of objects when they die, and the assignment of
When it comes to a class type object, the replication form and the direct form of the initialization are different: direct initialization calls directly to the constructor that matches the argument, and replication initialization always calls the
Priority Level
operator
Description
Example
combination of
1
()[]->.::++--
Bracket operator for adjusting precedenceArray Subscript access operatorTo access a member's operator by pointing to an object's pointerTo
Introduction of Smart pointers: the implementation principle of smart pointers: resource allocation is initialized RAII (Resource acquisition is initialization):
Define a class to encapsulate the allocation and release of resources, when the
Priority Level
operator
Description
Example
combination of
1
()[]->.::++--
Bracket operator for adjusting precedenceArray Subscript access operatorTo access a member's operator by pointing to an object's pointerTo
Objective
This article summarizes the copy constructors and overloaded assignment operators in C + +, including the following:
1. Copy the constructor and the definition of the overloaded assignment operator;2. The timing of the invocation of the
In c++11, the default functions and deleted functions allow you to explicitly control whether special member functions are automatically generated. A deleted function can also provide you with a simple language to prevent problematic type elevation
Basic Operators
An operator is a special symbol or phrase that is used to examine, manipulate, and combine values. For example, add a plus sign (+) that adds two values (let i = 1 + 2). More complex such as logic and (&&), self-increment (++i:
Now, the reader must be eager to write programs to allow actual interaction between the computer and the outside world. We do not want the program to only work as a typist and display fixed information contained in the program code. Indeed, the
1 default functionDesign a class with no member functions (member function), only member data (member)class dataonly {private: std::string strName; // member data int IData;};1.1 Special member functionsThe c++98 compiler implicitly
The C ++ operator is explained in detail in conjunction with the instance.C ++ operators combined with Instances
An operator is a symbol that tells the compiler to execute a specific mathematical or logical operation. C ++ has built-in rich
C ++ 11: "= delete", 11 delete
1 default Function
Design a class with no member function and only member data)
class DataOnly {private: std::string strName; // member data int iData;};
1.1 special member functions
The C ++ 98
Arithmetic operators
operator
Description
Example
+
Add-two Objects added
A + B output result 31
-
Minus-get negative numbers or one number minus the other
-b Output result-1
Copy constructor, direct initialization, copy initialization, assignment, temporary object
Several questions should be clarified about the replication constructor: when to call the replication constructor, what are the features of the replication
Typical programming questions for famous enterprise interviewers: C ++
C ++
Most colleges and universities in China offer C ++ courses, so most programmers have learned C ++. Therefore, C ++ has become the preferred programming language for various
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.