Please enable JavaScript.
Coggle requires JavaScript to display documents.
MAP, pointers
Nurmukhanbetova Laura, Bayakhmet Yesendir. Pointer and…
MAP
In C++, special members are specific member functions that the compiler automatically generates for a class when you don’t provide them. These special members are crucial for managing resource allocation, object copying, and object destruction. The main special members are:
Default Constructor: A constructor that can be called with no arguments. It initializes objects when no initial values are provided.
Copy Constructor: A constructor that creates a new object as a copy of an existing object. It takes a reference to an object of the same class.
Copy Assignment Operator: An operator that assigns the contents of one object to another existing object of the same class.
Move Constructor: A constructor that transfers resources from a temporary object (rvalue) to a new object, enabling efficient resource management.
Move Assignment Operator: An operator that transfers resources from one existing object to another existing object, allowing for efficient assignment of temporary objects.
-
Destructor: A function that is called when an object goes out of scope or is explicitly deleted. It is responsible for freeing resources allocated to the object.
Alexey Vachshenko, Zakayev Temirlan Special members
-
-
The default constructor is the constructor that takes no parameters, and it is special because it is called when an object is declared but is not initialized with any arguments.
Rectangle rectc(); // oops, default constructor NOT called
The way of calling constructors by enclosing their arguments in parentheses, as shown above, is known as functional form.
-
-
Function overloading is a feature of object-oriented programming where two or more functions can have the same name but different parameters.
C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading. Operator overloading is a compile-time polymorphism. For example, we can overload an operator ‘+’ in a class like String so that we can concatenate two strings by just using +.
This feature of OOPS concepts enables the programmer to develop a function with a name unchanged, but with different execution behavior thereby making the code more readable and reusable.
There are certain rules to be followed while overloading a function in C++. Let us have a look at some of them:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-