I have a class Student which inherits from Person. Both classes just have the defined virtual function printDetails() and their constructors.
Person student = Student("John Smith", "a1234567");
student.printDetails();
When i have the code above in my main the printDetails() function is called in the Person class.
Person* student = new Student("John Smith", "a1234567")
student->printDetails()
However when i have the dynamically allocated version above the function is called by the student.
My question is, why is printDetails() being called in the Person class rather then in the Student one for the first segment of code?