PR3-Rust-SS26/D-ownership/example-code/02-ownership/memory-leak.cpp

9 lines
187 B
C++

#include <iostream>
int main() {
char* ptr1 = new char[5]{'h', 'e', 'l', 'l', 'o'};
char* ptr2 = ptr1;
std::cout << ptr1 << std::endl;
} // Memory leak since nothing is released!