From deeb409ab2b0e1aeeb5dcdc0f21ed2f2462298e5 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 28 Nov 2022 10:40:48 +0100 Subject: fix class reference --- oop2w3/A.cpp | 2 +- oop2w3/A.h | 2 +- oop2w3/B.cpp | 2 +- oop2w3/B.h | 2 +- oop2w4/main.cpp | 0 oop2w4/makefile | 1 + 6 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 oop2w4/main.cpp create mode 120000 oop2w4/makefile diff --git a/oop2w3/A.cpp b/oop2w3/A.cpp index b6f0d57..ccdca46 100644 --- a/oop2w3/A.cpp +++ b/oop2w3/A.cpp @@ -18,7 +18,7 @@ void A::actie1(int n) { } } -void A::setB(B b) { +void A::setB(B &b) { std::cout << "A::setB(b)" << std::endl; _b = &b; } diff --git a/oop2w3/A.h b/oop2w3/A.h index c0caae4..2882fe7 100644 --- a/oop2w3/A.h +++ b/oop2w3/A.h @@ -7,6 +7,6 @@ class A { B* _b; public: A(); - virtual void setB(B b); + virtual void setB(B &b); virtual void actie1(int n); }; diff --git a/oop2w3/B.cpp b/oop2w3/B.cpp index 6eb4bd2..42ae7de 100644 --- a/oop2w3/B.cpp +++ b/oop2w3/B.cpp @@ -3,7 +3,7 @@ #include "A.h" #include "B.h" -B::B(A a) { +B::B(A &a) { std::cout << "B::B(a)" << std::endl; _a = &a; _c = new C(); diff --git a/oop2w3/B.h b/oop2w3/B.h index 081dc8b..a59a06f 100644 --- a/oop2w3/B.h +++ b/oop2w3/B.h @@ -8,7 +8,7 @@ class B { A* _a; C* _c; public: - B(A a); + B(A &a); virtual void even(); virtual void odd(int i); virtual void actie2(int i); diff --git a/oop2w4/main.cpp b/oop2w4/main.cpp new file mode 100644 index 0000000..e69de29 diff --git a/oop2w4/makefile b/oop2w4/makefile new file mode 120000 index 0000000..a4e84c6 --- /dev/null +++ b/oop2w4/makefile @@ -0,0 +1 @@ +../week.mk \ No newline at end of file -- cgit v1.2.3