尝试访问 Hand 类中的结构成员,但出现以下错误:错误:C2228:'.colorBet' 左侧必须有类/结构/联合
手.h
#ifndef HAND_H
#define HAND_H
#include"deck.h"
#include <QVector>
#include <QString>
struct street
{
QString colorBet;
int colorBetSize;
int payout;
};
class Hand
{
QVector<card> cardVector;
public:
Hand(QVector<card> vCards);
bool isFlush();
bool isAllRed();
bool isAllBlack();
street street1;
street street2;
street street3;
};
#endif // HAND_H
mainwindow.cpp(底部附近的错误)
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "hand.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::build_radios(){
street1BetBlack = new QRadioButton("Black");
connect(street1BetBlack, SIGNAL(clicked()),
this, SLOT(street1BetBlackClicked()));
street2BetBlack = new QRadioButton("Black");
connect(street2BetBlack, SIGNAL(clicked()),
this, SLOT(street2BetBlackClicked()));
street3BetBlack = new QRadioButton("Black");
connect(street3BetBlack, SIGNAL(clicked()),
this, SLOT(street3BetBlackClicked()));
street1BetRed = new QRadioButton("Red");
connect(street1BetRed, SIGNAL(clicked()),
this, SLOT(street1BetRedClicked()));
street2BetRed = new QRadioButton("Red");
connect(street2BetRed, SIGNAL(clicked()),
this, SLOT(street2BetRedClicked()));
street3BetRed = new QRadioButton("Red");
connect(street3BetRed, SIGNAL(clicked()),
this, SLOT(street3BetRedClicked()));
st1bg = new QButtonGroup;
st2bg = new QButtonGroup;
st3bg = new QButtonGroup;
// button groups
st1bg->addButton(street1BetBlack);
st1bg->addButton(street1BetRed);
st1bg->setExclusive(true);
st2bg->addButton(street2BetBlack);
st2bg->addButton(street2BetRed);
st2bg->setExclusive(true);
st3bg->addButton(street3BetBlack);
st3bg->addButton(street3BetRed);
st3bg->setExclusive(true);
}
void MainWindow::street1BetRedClicked()
{
Hand::street1.colorBet="Red"; //error on every line similar to this
}
void MainWindow::street2BetRedClicked()
{
Hand::street2.colorBet="Red";
}
void MainWindow::street3BetRedClicked()
{
Hand::street3.colorBet="Red";
}
void MainWindow::street1BetBlackClicked()
{
Hand::street1.colorBet="Black";
}
void MainWindow::street2BetBlackClicked()
{
Hand::street2.colorBet="Black";
}
void MainWindow::street3BetBlackClicked()
{
Hand::street3.colorBet="Black";
}