Thank you both for your time :
@J-M-L : I tried all combinations of variables, pointers and references. When I did your suggestion the errors are :
sketch\Puzzle.cpp: In member function 'void Puzzle::setup()':
Puzzle.cpp:6:21: error: no matching function for call to 'Box::Box(Debug*)'
_box = Box(&_debug);
^
In file included from sketch\Puzzle.h:5:0,
from sketch\Puzzle.cpp:1:
sketch\Box.h:10:5: note: candidate: Box::Box(Debug&)
Box(Debug &debug);
^~~
sketch\Box.h:10:5: note: no known conversion for argument 1 from 'Debug*' to 'Debug&'
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(const Box&)
class Box {
^~~
sketch\Box.h:6:7: note: no known conversion for argument 1 from 'Debug*' to 'const Box&'
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(Box&&)
sketch\Box.h:6:7: note: no known conversion for argument 1 from 'Debug*' to 'Box&&'
sketch\Box.cpp: In constructor 'Box::Box(Debug&)':
Box.cpp:5:9: error: invalid initialization of non-const reference of type 'Debug&' from an rvalue of type 'Debug*'
_debug(&debug) {
^~~~~~
Main:3:8: error: use of deleted function 'Puzzle::Puzzle()'
Puzzle puzzle;
^~~~~~
In file included from D:\project\escape\puzzle box\source\Main\Main.ino:1:0:
sketch\Puzzle.h:7:7: note: 'Puzzle::Puzzle()' is implicitly deleted because the default definition would be ill-formed:
class Puzzle {
^~~~~~
Puzzle.h:7:7: error: no matching function for call to 'Box::Box()'
In file included from sketch\Puzzle.h:5:0,
from D:\project\escape\puzzle box\source\Main\Main.ino:1:
sketch\Box.h:10:5: note: candidate: Box::Box(Debug&)
Box(Debug &debug);
^~~
sketch\Box.h:10:5: note: candidate expects 1 argument, 0 provided
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(const Box&)
class Box {
^~~
sketch\Box.h:6:7: note: candidate expects 1 argument, 0 provided
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(Box&&)
sketch\Box.h:6:7: note: candidate expects 1 argument, 0 provided
exit status 1
no matching function for call to 'Box::Box(Debug*)'
@johnwasser : things are a little more complicated because I also need to initialize _debug as well as _box. I tried a few setups and could not make any progress. For example...
void Puzzle::setup() :
_debug(Debug()),
_box(_debug)
{
_debug.line("Puzzle Setup");
}
Resulted in the following errors :
sketch\Puzzle.cpp: In member function 'void Puzzle::setup()':
Puzzle.cpp:5:3: error: only constructors take member initializers
_debug(Debug()),
^~~~~~
sketch\Box.cpp: In constructor 'Box::Box(Debug&)':
Box.cpp:5:9: error: invalid initialization of non-const reference of type 'Debug&' from an rvalue of type 'Debug*'
_debug(&debug) {
^~~~~~
Main:3:8: error: use of deleted function 'Puzzle::Puzzle()'
Puzzle puzzle;
^~~~~~
In file included from D:\project\escape\puzzle box\source\Main\Main.ino:1:0:
sketch\Puzzle.h:7:7: note: 'Puzzle::Puzzle()' is implicitly deleted because the default definition would be ill-formed:
class Puzzle {
^~~~~~
Puzzle.h:7:7: error: no matching function for call to 'Box::Box()'
In file included from sketch\Puzzle.h:5:0,
from D:\project\escape\puzzle box\source\Main\Main.ino:1:
sketch\Box.h:10:5: note: candidate: Box::Box(Debug&)
Box(Debug &debug);
^~~
sketch\Box.h:10:5: note: candidate expects 1 argument, 0 provided
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(const Box&)
class Box {
^~~
sketch\Box.h:6:7: note: candidate expects 1 argument, 0 provided
sketch\Box.h:6:7: note: candidate: constexpr Box::Box(Box&&)
sketch\Box.h:6:7: note: candidate expects 1 argument, 0 provided
exit status 1
only constructors take member initializers