Last active
August 29, 2015 14:21
-
-
Save onqtam/0f20ea4038f0f61adc63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct A { | |
virtual void foo() = 0; | |
}; | |
struct B { | |
virtual void foo() = 0; | |
}; | |
struct CA : A { | |
void foo() override { std::cout << "A" << std::endl; } | |
}; | |
struct CB : B { | |
void foo() override { std::cout << "B" << std::endl; } | |
}; | |
struct C : CA, CB { | |
//void foo() override { std::cout << "C" << std::endl; } // if this is provided the ones from CA and CB will be overridden | |
}; | |
int main() { | |
C c; | |
//c.foo(); // ambiguous | |
A& a = c; | |
a.foo(); | |
B& b = c; | |
b.foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment