diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 18:41:08 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-10 18:41:08 +0100 |
commit | a95f51e847892fe0e358c519cc4bac42382fbbb7 (patch) | |
tree | 3b3a9be7e4407d20b39200c3a7391fd7b1ee807d /tests/typing/bad/diamond.cpp | |
parent | 7770d251f3cf41e04b49067ba4bd6e45d87fd2d1 (diff) | |
download | LPC-Projet-a95f51e847892fe0e358c519cc4bac42382fbbb7.tar.gz LPC-Projet-a95f51e847892fe0e358c519cc4bac42382fbbb7.zip |
Correct a typing bug in multiple inheritance (all virtual instances in parents must be updated when virtual method is redefined.)
Diffstat (limited to 'tests/typing/bad/diamond.cpp')
-rw-r--r-- | tests/typing/bad/diamond.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/typing/bad/diamond.cpp b/tests/typing/bad/diamond.cpp new file mode 100644 index 0000000..fe59ceb --- /dev/null +++ b/tests/typing/bad/diamond.cpp @@ -0,0 +1,33 @@ +#include <iostream> + + +class A { public : + int a; +}; + +class B : public A { public : + int b; +}; + +class C : public A { public : + int c; +}; + +class D : public B, public C { public : + int d; +}; + + + +void f(A* ap) {std::cout << ap->a << "\n";} + +int main () { + + D* dp = new D(); + dp->a = 42; + std::cout << dp-> a << "\n"; + + f(dp); + + return 0; +}
\ No newline at end of file |