###前提・実現したいこと
layer_StatusというクラスでPlayer_Goldというクラスから
Plus_goldとMinus_goldという2つの関数を使おうとしています
###発生している問題・エラーメッセージ
エラーメッセージ
warning C4715: 'Player_Status::Gold_Cul' : 値を返さないコントロール パスがあります。
###該当のソースコード
/////////////////////////////include.h/////////////////////
#define MAXLEVEL 30
#define MAXEXP 9999
#define MAXGOLD 9999
#define MAXPOSX 100
#define MAXPOSY 100
#define PLUS 1
#define MINUS 2
#include <cassert>
#include <algorithm>
/////////////////////////////Player_Status.h///////////////
#pragma once
class Player_Gold
{
private:
int m_gold;
public:
Player_Gold(int init_gold=0);
~Player_Gold();
bool Plus_gold(int);
bool Minus_gold(int);
int Get_Gold();
};
class Player_Status
{
private:
Player_Gold* P_Gold;
Player_Level* P_Level;
Player_Seed* P_Seed;
Player_Stage* P_Stage;
Player_Destroy* P_Destroy;
public:
void InitSatus();
bool Gold_Cul(Player_Gold*, int, int);
void Exp_Cul(Player_Level*, int);
bool Seed_Cul(Player_Seed*, int, int, int);
bool Destroy_Per_Cal(Player_Destroy*, int);
};
/////////////////////////////Player_Status.cpp/////////////
bool Player_Status::Gold_Cul(Player_Gold* P_Gold, int Gold ,int CulType)
{
assert(CulType==PLUS||CulType==MINUS);
if (CulType == PLUS)
{
return P_Gold->Plus_gold(Gold);
}
if (CulType == MINUS)
{
return P_Gold->Minus_gold(Gold);
}
}
///////////////////////////Player_gold_cpp/////////////////
bool Player_Gold::Plus_gold(int gold)
{
assert(0<gold&&gold<MAXGOLD);
if ((m_gold + gold) > MAXGOLD)
{
m_gold = MAXGOLD;
return false;
}
m_gold += gold;
return true;
}
bool Player_Gold::Minus_gold(int gold)
{
assert(0<gold&&gold<MAXGOLD); if ((m_gold - gold) < 0) { return false; } m_gold -=gold; return true;
}
###試したこと
書きなおしてみたんですがなぜfalseとtureで戻り値が出るはずなのに
エラーが出てしまいます優しく教えていただけたら幸いです
回答4件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。