Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What are the special member functions that the compiler will write for you if

ID: 3720422 • Letter: 1

Question

1. What are the special member functions that the compiler will write for you if you don’t? (Hint: There are 6 of them.)

2. What do the default copy constructor and copy assignment operator do?

3. What do the default constructor and destructor do?

4. What is the difference between copy assignment and copy initialization?

5. How do you prevent the compiler from generating a special member function?

6. What is the difference between moving and copying?

7. When will the compiler use move assignment or initialization rather than copy assignment or

Initialization?

8. There are situations in which you would like to allow objects to be moved, but not copied. What do you need to do to prevent copying while allowing objects to be moved?

Explanation / Answer

1. What are the special member functions that the compiler will write for you if you don’t? (Hint: There are 6 of them.)

Answer)
There are some special member functions that the compiler will write for you if you don’t. There are about 6 of them. So I will try to explain and tell about them. These special member functions are:

a) Compiler creates a default constructor when you don't create a constructor in the program
b) Similarly, compiler generate a c copy constructor when you don't declare that as well
c) Compiler generates a copy assignment operator when the programmer doesn't declare it
d) Compiler generates a destructor when the programmer does not specify a destructor in the program
e) Compiler creates a Move constructor implicitly
f) Compiler generates a Move assignment operator implicitly