summaryrefslogtreecommitdiff
path: root/tests/exec/multisuper1.cpp
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-08 22:59:02 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-08 22:59:02 +0100
commitce876db1ef52af3c0b1a89b18a08279a5aea3d9d (patch)
tree8abc918f6db7a3e9eaeb83d5900053bac8b4cde5 /tests/exec/multisuper1.cpp
parent97962c7823fd8bfca3a94909bb4b6f14ad967735 (diff)
parent56fdab2ff0caaaa88a152ef06aef821f432fe488 (diff)
downloadLPC-Projet-ce876db1ef52af3c0b1a89b18a08279a5aea3d9d.tar.gz
LPC-Projet-ce876db1ef52af3c0b1a89b18a08279a5aea3d9d.zip
Merge branch 'codegen-alex' into codegen-alex-opt
Diffstat (limited to 'tests/exec/multisuper1.cpp')
-rw-r--r--tests/exec/multisuper1.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/exec/multisuper1.cpp b/tests/exec/multisuper1.cpp
new file mode 100644
index 0000000..48014f7
--- /dev/null
+++ b/tests/exec/multisuper1.cpp
@@ -0,0 +1,57 @@
+#include <iostream>
+
+class A {
+ public:
+ int y;
+ A();
+ int f(int x);
+};
+
+class B {
+ public:
+ int z;
+ B();
+ int g(int x);
+};
+
+class C : public A, public B {
+ public:
+ int q;
+ C();
+ int f(int x);
+};
+
+A::A() {
+ y = 12;
+}
+
+B::B() {
+ z = 7;
+}
+
+C::C() {
+ q = 11;
+}
+
+int A::f(int x) {
+ return x * y;
+}
+
+int B::g(int x) {
+ return x * z;
+}
+
+int C::f(int x) {
+ return x * q;
+}
+
+int main() {
+ C test;
+ std::cout << "C.f(1) = " << test.f(1) << "\n";
+ std::cout << "C.g(1) = " << test.g(1) << "\n";
+ A *q = &test;
+ std::cout << "A.f(1) = " << q->f(1) << "\n";
+ B *r = &test;
+ std::cout << "B.g(1) = " << r->g(1) << "\n";
+}
+