Reputation: 331
Even though there are so many articles on how virtual functions are handled in c++, i could not clear one basic doubt. Is vptr variable of derived class overrided by base class variable. Is the ptr varible also name mangled?
Class Base
{
public:
virtual void test();
};
class Derived
{
public:
virtual void test();
};
If I call
Base b = new Derived();
b->test();
It transforms to
(*b->vptr[<index>])(b);
Where index points to vtable entry.
My doubt is whether is this vptr also name mangled ?
Upvotes: 1
Views: 604
Reputation: 27470
You cannot access vptr in C++ by language means so answer in "no" - no such variable and name and thus no its mangling :)
Upvotes: 1
Reputation: 4436
The C++ standard doesn't even acknowledge the existence of a vptr
in polymorphic classes because it's an implementation detail and therefore it isn't even a requirement that compilers implement virtual functions in this way. So no, vptr
is not a reserved keyword (which is what I think you're trying to ask).
Upvotes: 9