我想确保我正确调用函数。另一个.cpp中的函数是makeDeck()
和shuffle()
。我也不知道如何制作相关的头文件或何时有用。有人可以编写或引导我查看将使用以下内容的deck.cpp
和deck.h
文件的语法:
main.cpp
#include <iostream>
#include "deck.h"
using namespace std;
int main() {
int size;
do {
cout << "Enter size of deck (5-50): " << endl;
cin >> size;
} while (size<5 || size>50);
int** deck[size] = makeDeck(size);
shuffle(deck);
int score = 0;
char guess = NULL;
for (int** i = **deck; *i != NULL; i++) {
cout << "Score: " + score << endl;
cout << "Current card: " + *i<< endl;
cout << "Will the next card be higher (high) or lower (low) than " + *i + "?" << endl;
cin << guess;
if (guess == "higher" || guess == "high") {
if (*(i + 1) > *i)
score++;
else
score--;
}
if (guess == "lower" || guess == "low") {
if (*(i + 1) < *i)
score++;
else
score--;
}
}
}