CJCoding With Joseph
15free / daySign inCreate account
Back to Multiple Choice Quiz

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

Topics

Missing Destructor

C++ quiz · Question 29
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}