Hard
To prevent class objects from being copied:
Author: Abha AgrawaStatus: PublishedQuestion passed 526 times
Edit
-1
Community Evaluations
Spelling / formatting error
Auteur anonyme10/02/2025
Est-ce que "(1) (2) and (3)" fait référence aux autres réponses ?
Si oui, ce n'est pas clair.
---
"To prevent class objects from being copied"
Pourquoi le point 3 est-il correct ? Si tous les constructeurs sont privés, on ne peut même instancier la classe. Puis, si on ne défini aucun constructeur, on pourra copier la classe (et le point 3 reste respecté).
---
La dernière phrase insinue que c'est soit la 1, soit la 2, soit la 3. Mais juste la 1 ou la 2 ne fonctionneraient pas.
---
Il serait préférable de déclarer le constructeur et l'operateur de copie `deleted`.
3
C++: what is the output of the following code? `std::cout << &obj << std::endl;`3
Write a C++ function that returns the sum of two integers.2
What is the value of p1 and q1 in the following code?
```c++
int i = 0;
int *p = &i;
int *const p1 = &i;
int *const q1 = &*p;
```2
What is the difference between a friend and a friend function in C++?2
Write a C++ program that creates an array of 10 Person objects.2
What is the output of the following C++ code?1
C++ is a general-purpose programming language. It was developed in the 1970s by Bjarne Stroustrup at Bell Labs.