So my professor likes to test us with code on a paper that we're supposed to figure out. I'm not going to post the code cause I'm not looking for an answer, it's just one thing that he used to confuse us was when he initialized an object of one class, then initialized a pointer of another class to point to the aforementioned object. it confused the hell out of me and it's such a specific problem that I didn't know how to search for it. Example:
class A {
// etc
}
...
class D {
void fy(etc, etc, etc) {}
// etc
}
class E: public D {
void fy(etc, etc, etc) {}
// etc
}
main() {
E e
D *d = &e
d->fy(15,25)
//everything else
does "d->fy()" do the fy() function of D or E? if D's fy() function was virtual, would it do E's then?
what the hell does the pointer do when it's from one class but points to an object of another? I know this question might have been answered before but I can't find it anywhere so I would even appreciate just being directed to the answer. Thank you very much.