← Back to Question List
C++ Quiz #29
Missing Destructor
This code compiles and runs, but it has a problem. What is the issue?
📄 Code
1#include <iostream>2using namespace std;34class Buffer {5public:6 int* data;7 Buffer(int size) {8 data = new int[size];9 }10 // No destructor defined11};1213int main() {14 Buffer b(100);15 b.data[0] = 42;16 cout << b.data[0] << endl;17 return 0;18}