質問の意図がよくわからないですが、C++をあまり勉強していない人が、Cのプログラムのグローバル変数やグローバル関数をクラスの中に入れようとしていると仮定して回答します。
まずポインタか参照をわたさない限り別のクラスのメンバ関数は呼べません。
次にヘッダファイル.hと、ソースファイル.cppを適切に分けないとダメです。
要するに質問にcppファイルしかないところで既にダメです。
そして場合によってはクラスの前方宣言やfriend宣言が必要です。
cpp
1// a.h
2#pragma once
3const int BOARD_SIZE = 19;
4class GO_MONTE_CARLO
5{
6 friend class NABI;
7
8private:
9 double Get_Criticality(int sel_x, int sel_y) const;
10 double Get_MaxCriticality() const;
11 int play_out_count;
12 double set_win_storn_num[BOARD_SIZE][BOARD_SIZE];
13 double set_white_num[BOARD_SIZE][BOARD_SIZE];
14 double set_black_num[BOARD_SIZE][BOARD_SIZE];
15 double white_win_num, black_win_num;
16};
cpp
1// b.h
2#pragma once
3#include "a.h"
4class NABI
5{
6public:
7 static double max_criticality(const GO_MONTE_CARLO& gm);
8};
cpp
1// a.cpp
2#include "a.h"
3#include "b.h"
4#include <float.h>
5double GO_MONTE_CARLO::Get_Criticality(int sel_x, int sel_y) const
6{
7 double N_p = (double)play_out_count + DBL_EPSILON;
8 double V_p = set_win_storn_num[sel_x][sel_y];
9 double W_p = set_white_num[sel_x][sel_y];
10 double B_p = set_black_num[sel_x][sel_y];
11 return (V_p / N_p) - (W_p / N_p * (double)white_win_num / N_p + B_p / N_p * (double)black_win_num / N_p);
12}
13double GO_MONTE_CARLO::Get_MaxCriticality() const
14{
15 return NABI::max_criticality(*this);
16}
cpp
1// b.cpp
2#include "b.h"
3double NABI::max_criticality(const GO_MONTE_CARLO& gm)
4{
5 double max_value = 0.0;
6 for (int i = 1; i <= BOARD_SIZE; ++i) {
7 for (int j = 1; j <= BOARD_SIZE; ++j) {
8 double value = gm.Get_Criticality(i - 1, j - 1);
9 if (max_value < value) max_value = value;
10 }
11 }
12 return max_value;
13}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/17 12:58
2018/01/17 14:54
2018/01/18 03:48