/*
* Copyright ©2026 Soham Pardeshi. All rights reserved.
* Permission is hereby granted to students registered for University of
* Washington CSE 333 for use solely during Summer Quarter 2026 for
* purposes of the course. No other use, copying, distribution, or
* modification is permitted without prior written consent. Copyrights
* for third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the author.
*/
#include <iostream>
#include "Point.h"
int main(int argc, char** argv) {
int stack_int; // stack-allocated int
int* heap_int = new int; // heap-allocated, uninitialized int
int* heap_int_init = new int{12}; // heap-allocated, initialized to 12
int stack_arr[3]; // stack-allocated array of 3 uninitialized ints
int* heap_arr = new int[3]; // heap-allocated array of 3 uninitialized ints
// Value initialize array elements (to zeros).
int* heap_arr_init_val = new int[3](); // heap-alloc array of 3 zeros
// C++11: can use a braced list of element initializers.
// if initializer list is short, remaining elements are value initialized.
int* heap_arr_init_lst = new int[3]{4, 5}; // heap-alloc array of {4, 5, 0}
Point stack_pt(1, 2); // stack-allocated Point object.
Point* heap_pt = new Point(1, 2); // heap allocated Point object.
// would be OK if we had a default constructor for Points, but
// since we don't, the compiler complains.
// Point *heap_pt_arr_err = new Point[2]; // heap-alloc, value initialized
// C++11: can use a braced list of element initializers.
Point* heap_pt_arr_init_lst = new Point[2]{{1, 2}, {3, 4}};
delete heap_int; // correct
delete heap_int_init; // correct
delete heap_pt; // correct
delete heap_arr; // incorrect! should be delete[] heap_arr
delete[] heap_arr_init_val; // correct
delete[] heap_pt_arr_init_lst; // correct
// memory leak of heap_arr_init_lst!
return EXIT_SUCCESS;
}