did i get it right?

i do not understand some parts of it

1)Override the Student's OutputIdentity() pure virtual method to display the text "I am a student" to the console

2)Override the Student's OutputAge() virtual method to display the text "I am a student" and then calls the Person class's OutputAge() method
how do i call the person class outputage method?is it saying that i call the person's class outputage method using student1 pointer or create a new pointer pointing to a person's class object and use that pointer to call that method?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  #include <iostream>
#include "Person.h"
#include "Student.h"
#include "Teacher.h"
using namespace std;

int main()
{
    Student obj("marcus","carcass",87654321);
    Person *student1 = &obj;
    student1->OutputIdentity();//step 8
    student1->OutputAge();
cout<<endl;
    Teacher ob("tim","dim",12345678);
    Person *teacher1 = &ob;
    teacher1->OutputIdentity();
    teacher1->OutputAge();
}
#ifndef PERSON_H
#define PERSON_H

using namespace std;
class Person
{
    public:
        Person();

        string first_name;
        string last_name;

        virtual void OutputIdentity()=0;
        virtual void  OutputAge();
    protected:
        int phone;
    private:
        int age;
};
#endif // PERSON_H

#include <iostream>
#include "Person.h"
#include "Student.h"
#include "Teacher.h"
using namespace std;

Person::Person()
{

}


void  Person::OutputAge(){
          cout<<"i am "<<age<<" years old";
}

To override something from Student, you must first inherit from Student.
Topic archived. No new replies allowed.