Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
#include
#include
using namespace std; class Hotel { public: string* guests; Hotel(int rooms) { guests = new string[rooms]; // Get memory cout << "Rooms ready\n"; } ~Hotel() { delete[] guests; // Free the memory cout << "Memory freed\n"; } }; int main() { Hotel myHotel(3); myHotel.guests[0] = "Liam"; cout << "Guest: " << myHotel.guests[0] << "\n"; return 0; }
Rooms ready
Guest: Liam
Memory freed