From a95f51e847892fe0e358c519cc4bac42382fbbb7 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Fri, 10 Jan 2014 18:41:08 +0100 Subject: Correct a typing bug in multiple inheritance (all virtual instances in parents must be updated when virtual method is redefined.) --- tests/exec/multi_virt.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/exec/multi_virt.cpp (limited to 'tests/exec/multi_virt.cpp') diff --git a/tests/exec/multi_virt.cpp b/tests/exec/multi_virt.cpp new file mode 100644 index 0000000..c0950b7 --- /dev/null +++ b/tests/exec/multi_virt.cpp @@ -0,0 +1,46 @@ +#include + +class A { public : int a; virtual void fa();}; +class B { public : int b; virtual void fb(); virtual void h();}; + +class C : public A, public B { public : int c; virtual void fc();}; + +class D { public : int d; virtual void fd(); virtual void h();}; +class E : public C, public D { public : int e; virtual void fb(); virtual void fd(); virtual void h();}; + +void B::fb() {std::cout << "B::fb";} +void E::fb() {std::cout << "E::fb";} +void A::fa() {std::cout << "A::fa";} +void D::fd() {std::cout << "D::fd";} +void E::fd() {std::cout << "E::fd";} +void C::fc() {std::cout << "E::fc";} + +void E::h() {std::cout << "E::h";} +void B::h() {std::cout << "B::h";} +void D::h() {std::cout << "D::h";} + + +int main() { + + E* cp = new E(); + cp->h(); + std::cout << "\n"; + cp->fd(); + std::cout << "\n"; + + D* dp = new E() ; + dp->h(); + std::cout << "\n"; + dp->fd(); + std::cout << "\n"; + + A* ap = new C() ; + ap->fa(); + + std::cout << "\n"; + + return 0; +} + + + -- cgit v1.2.3