Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
VC++ fail
#include <iostream> struct Base { virtual int foo() { return 404; }; }; struct A : Base { int foo() override { return 1; } }; struct B : Base { int foo() override { return 2; } }; namespace { bool shouldCreateA() { return false; } } int main() { Base&& obj = shouldCreateA() ? static_cast<Base&&>(A{}) : static_cast<Base&&>(B{}); std::cout << obj.foo(); }
run
|
edit
|
history
|
help
0
PreprocessorVsNamespace
Enum Class Comparisons
sharedptr emptiness
amusing overload choice
make Derive final
hangman
Thing v.2
no-thread
#32
hangman