When read from top to bottom, the compiler first comes across a identifer "Student" on line 9. At this point, it has no idea what a Student is.
You can circumvent this by adding a declaration of the student class before your Teacher class.
In this case you may need to separate implementation from interface for this or else you might get compiler errors about incomplete type usage.
Another problem is that Student::grade refers to no object. It's simply a data member of the Student class.
You need to pass in an actual Student object into your function in order to mutate that.
Something like