나는 모든 값과 함수를 가지는 포인터의 배열을 가지고 있습니다. 함수가 실행될 때 값을 찾을 수없는 것처럼 보입니다.함수의 포인터의 배열의 배열
프로그램을 중단시키는 코드는 거의 맨 아래에 있습니다.
내 클래스의 .H 파일 :
이#ifndef DICE_H
#define DICE_H
class Dice
{
public:
int value;
int nrOfFaces;
Dice();
void toss();
};
#endif
그리고 내 클래스에 대한 내 .cpp 파일 :
이#include "Dice.h"
#include <cstdlib>
using namespace std;
Dice::Dice()
{
nrOfFaces = 6;
value = 0;
}
//this function gives the dice a new random value
void Dice::toss()
{
value = rand() % nrOfFaces + 1;
}
main() 함수 :
int main(){
srand(static_cast<unsigned>(time(NULL)));
Playboard* board = new Playboard();
Dice** dice = new Dice*[5];
int round = 0;
while (1){
system("CLS");
board->PrintBoard();
cout << endl;
cout << endl << "Press Enter to roll the dices" << endl;
getchar();
for (int i = 0; i < 5; i++)
{
dice[i]->toss(); //ERROR
cout << dice[i]->value << AddSpaces(2);
}
return 0;
}
당신이지고있는 오류 출력은 무엇입니까? – DeadChex