尝试使用外部声明的类对象,但收到错误。
赌注.h
#ifndef WAGER_H
#define WAGER_H
#include <QString>
void won_color_bets(int cardsDealt);
class Wager
{
int bet;
int payout;
public:
bool didBet;
bool won;
QString colorBet;
QString colorResult;
Wager();
};
extern Wager street1;
#endif // WAGER_H
赌注.cpp
#include "wager.h"
#include "deck.h"
#include<QDebug>
#include<QVector>
#include<QList>
#include"mainwindow.h"
Wager street1;
Wager street2;
Wager street3;
Wager street4;
Wager street5;
主窗口.cpp
void MainWindow::street1BetRedClicked()
{
street1.colorBet="Red";
qDebug()<<"street1Red Clicked";
}
mainwindow.obj:-1:错误:LNK2001:未解析的外部符号“class Wager street1”(?street1@@3VWager@@A)
street1Red Clicked
调试成功输出