What is the correct way to initialize a constructor of an abstract class? I commented out the constructor in the cc file and it seemed to be working, I would like to understand why.
Board. h Board.h is an abstract class, as it has 2 pure virtual function NOT included here.
class Board {
public:
Board(size_t width, size_t height)
: width(width), height(height) {}
virtual ~Board() {}
....
protected:
//this is line 54
size_t height;
size_t width;
};
My localBoard.h
#include <Board.h>
class LocalBoard : public Board {
public:
LocalBoard(size_t width, size_t height) :Board(width),Board(height) {}
~LocalBoard() {}
...
};
LocalBoard.cc
#include <board/LocalBoard.h>
// commenting this out fixed the error
//LocalBoard(size_t width, size_t height) {}
error: multiple initializations of constructor
On an another note may someone help me understand what the following warning means, what consequences it has for my program and how to fix it? I think it related to the constructor again.
./include/board/Board.h: In constructor ‘Board::Board(size_t, size_t)’:
./include/board/Board.h:54:9: warning: ‘Board::width’ will be initialized after [-Wreorder]
size_t width;