Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
virtual inheritance
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #include <iostream> class base { public: virtual void func1() {} }; class base1 : virtual public base { public: virtual void func2() {} }; class base2 : virtual public base { public: virtual void func3() {} }; class base3 : public base1, public base2 { public: virtual void func2() { func1(); } }; int main() { base3 b3; b3.func2(); } /* without virtual on line 11, 17 we get the error Error(s): source_file.cpp(28): error C2385: ambiguous access of 'func1' source_file.cpp(28): note: could be the 'func1' in base 'base' source_file.cpp(28): note: or could be the 'func1' in base 'base' Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 because there is multiple copy of func1 in base3, virtual inheritence allows only 1 copy of the base class no matter how many times it's derived in the inheritance chain */
run
|
edit
|
history
|
help
0
MSVC_example_fscanf_s_and_chars_wchars
What is the fastest/most efficient way to find the highest set bit (msb) in an integer in C?
empty base bug
RVO hota hai bhenchod
!Enum
MSVC initializer code
Two-phase sample with Visual C++ 2015
Program of cube
Unicode_write2file
Computing factorial of an integer with recursion and iteration