委任されたコンストラクターを使用しようとしており、この質問とこの質問にある形式に従おうとしていますが、まだ問題があります。
私のplayer.h
ファイルはこれです:
#ifndef PLAYER_H_
#define PLAYER_H_
#include <string>
class Player
{
public:
Player(void);
Player(std::string name, int score);
~Player();
protected:
std::string name_;
int score_;
};
#endif
私のplayer.cpp
ファイルはこれです:
#include "player.h"
Player::Player(std::string name, int score)
{
score_ = score;
name_ = name;
}
Player::Player(void) : Player(NULL,0)
{
}
ただし、コンパイルしようとすると、次のエラーが発生します。
1>a:\projects\test\src\player.cpp(5): error C2614: 'Player' : illegal member initialization: 'Player' is not a base or member
私は何を間違っていますか?関連する場合は、VS2012 を使用しています。