From 622f76becf4b8cbf4a56daa913070487481b87cf Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Wed, 8 Jan 2014 22:51:33 +0100 Subject: Added tests for multiple inheritance. --- tests/exec/multisuper1.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tests/exec/multisuper1.cpp (limited to 'tests/exec/multisuper1.cpp') 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 + +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"; +} + -- cgit v1.2.3