Let say I've this code:
#include <iostream>
#include <array>
struct Base
{
virtual float getValue() { return 1.0f; }
};
struct Derived : Base
{
float getValue() override { return 2.0f; }
};
inline void test(Base *obj) {
std::cout << obj->getValue() << std::endl;
}
int main()
{
Derived d;
test(&d);
float value = d.getValue();
std::cout << value << std::endl;
}
I would say that most of the time, test(&d); is processed at runtime using vtable.
But what I looking for is how float value = d.getValue(); its compiled; since its know at "compile time", directly from the object which point to the target function, is it correct to state that this will never use vtable? (basically, its the same method called if it wasn't decleared virtual).