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 #29

Missing Destructor

easyRule of Three

This code compiles and runs, but it has a problem. What is the issue?

📄 Code

1#include <iostream>
2using namespace std;
3 
4class Buffer {
5public:
6 int* data;
7 Buffer(int size) {
8 data = new int[size];
9 }
10 // No destructor defined
11};
12 
13int main() {
14 Buffer b(100);
15 b.data[0] = 42;
16 cout << b.data[0] << endl;
17 return 0;
18}