Category : virtual

I have written the following code to understand c++’s virtual, override, hide, overload meaning. I expect fc->g() give me output Child:g(int):i = 20, but it gives me Child:g(int):i = 10. It seems the pointer fz call Child::g(int i) correctly by following links of vtbl(virtual table), but it fails to access the correct parameter value for ..

Read more

Is it possible to have a “non virtual pointer” in c++ ( ie a pointer that calls the methods directly without dynamic dispatch). This is because I am trying to do something like this: template <typename T> class Ref { T* value; // I am 100% sure that value points to an actual T object. ..

Read more