struct AStructT { int age; string name; }; class BookT { private: string title; string author; int pages; }; int anInt; int intArray[4]; AStructT person; BookT myBook;
type * identifier
int * intPtr;
int * ptr1, * ptr2;
int * intPtr = nullptr;
new DataType
is for a single instance of the data type.
new DataType [int expression]
is for an array.
DataType *
.
delete ptr
for a single instance
delete [] ptr
for the array version
int * a = nullptr, * b = nullptr, * c = nullptr; a = new int; b = a; c = new int; c = new int; delete a; a = nullptr; delete c; a = nullptr;