c++ - no matching function for call to ‘Board::Board()’ -
this erros happening , don't know why. first of , want make battleship game , got classes , need implement few functions. i'm starting drawing board i'm having bad time. if someone's interested or made before , give me little help, i'd appreciate lot. final project semester , got rope on neck.
here's problem.
i have board class
class board { public: board(const string &filename); //bool putship(const ship &s); void moveships(); //bool attack(const bomb &b); void display()const; void show()const; void initializegrid(); private: int numlines, numcolumns; //vector <ship> ships; vector <vector<int> > board; }; and player class
class player{ public: player(string playername, string boardfilename); void showboard() const; //bomb getbomb() const; //void attackboard(const bomb &b); private: string name; board board; }; and want create board reading dimensions txt (not done yet).
but when this:
player::player(string playername, string boardfilename){ name = playername; board = boardfilename; } and
void player::showboard() const{ board b01; } i following error:
no matching function call ‘board::board()’
you have declared following constructor:
board(const string &filename); due this, default constructor not generated. why error in following line:
board b01; // default ctor not exist
Comments
Post a Comment