小编Dev*_*ana的帖子

How to pass value to parameterized constructors if there objects are being created as data members of another class?

I am trying to make a Chess Game in C++ using OOPS concepts but face the following error:

src/Game.cpp:6:36: error: no matching function for call to ‘Player::Player()’
 Game::Game(): player1(1), player2(0){
                                    ^
In file included from include/Game.h:4:0,
                 from src/Game.cpp:2:
Run Code Online (Sandbox Code Playgroud)

Here is my code:

Player.h

#ifndef PLAYER_H
#define PLAYER_H
#include <string>
#include <King.h>
#include <Knight.h>
#include <Pawn.h>
#include <Queen.h>
#include <Bishop.h>
#include <Rook.h>
using namespace std;
class Player{
    public:
        Player(int color);
        void getMove();   
        int playerColor;             // 0 if player is black, 1 …
Run Code Online (Sandbox Code Playgroud)

c++ oop constructor class object

1
推荐指数
1
解决办法
68
查看次数

标签 统计

c++ ×1

class ×1

constructor ×1

object ×1

oop ×1