Notes: 1) Person is the base class of Student 2) Person contains name as the only data variable 3) Student contains society . The society acts as a pointer to a text string which contains the name of the student's club.
I have difficulty in understanding the fourth line:
int main (){
Person* p1;
p1=new Student("John", "Drama Society"); //This line
delete p1;
}
Isn't p1 a Person pointer pointing to a memory address in the heap? As far as I know, pointer variable is just a 32-bit or 64-bit(system-dependent) location in memory. How can it be initialized just like objects of type Person?
I know my concept is wrong, please help me find them out :(