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
Fibonacci stairs
ntohl
Override keyword.cpp
Operators overloading
std::is_same doesn't check for calling convention
Project
reference
hex manip
Sum of numbers in a series using sum formular
ToString library for C++