CJCoding With Joseph
15per day
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #30

Default Copy Double Free

easyRule of Three

This code compiles but crashes at runtime. What is the issue?

📄 Code

1#include <iostream>
2using namespace std;
3 
4class IntHolder {
5public:
6 int* value;
7 IntHolder(int v) {
8 value = new int(v);
9 }
10 ~IntHolder() {
11 delete value;
12 }
13};
14 
15int main() {
16 IntHolder a(10);
17 IntHolder b = a; // copy
18 return 0;
19}