C++ virtual method not called as expected
问题 I'm fiddling around with proper overriding of virtual methods. I chain some constructors and in the base class constructor I call a virtual method. Call chain should be as followed: B(p)->A(p)->B.foo(p) Call chain is in C++: B(p)->A(p)->A.foo(p) Call chain is in C#: B(p)->A(p)->B.foo(p) So in other words, in C# behaviour is like expected, in C++ it isn't. C++ Code: #include <cstdio> class A { public: A(); A(int); virtual void foo(int s); }; class B : public A { public: B(); B(int s) : A(s) {}