Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:37:26+00:00 2026-06-16T14:37:26+00:00

Trying to access a struct member in class Hand with the following error: error:

  • 0

Trying to access a struct member in class Hand with the following error: error: C2228: left of ‘.colorBet’ must have class/struct/union

hand.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 (error near the bottom)

#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";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:37:27+00:00Added an answer on June 16, 2026 at 2:37 pm

    Hand::street1.colorBet="Red"; & the others are illegal because Hand::street1 isn’t a static class member (I’m not saying it should, having static members should be a logic decision, not something you do to make the code compile).

    What Hand object are you attempting to modify in, say, street1BetRedClicked? Do you have any Hand objects? Do you need any Hand objects? Do you create them in that method? Outside?

    I pointed out the error, but it seems to me that the important issue here isn’t the fact that the code doesn’t compile, but that:

    1. You don’t seem to have a firm grasp on C++, perhaps you should start with something simpler.

    2. You don’t have a clear logic set up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access a member structs variables, but I can't seem to get
I was trying to do this, class Outer { public: struct inner_t { void
In C++, I'm trying to create a specialized point class as a union, like
Possible Duplicates: [FAQ] Why doesn't a derived template class have access to a base
I am trying to access an object which is a member of an object
I use the following code a lot in C: typedef struct { int member;
I am trying to access a C++ class and call its method from a
In main.C I am trying to access a nested structure member (g.Fp1.d_status) and am
Error accessing structure member inside using member function of class. Hello i am unable
I'm trying to translate the following code from C++ to C# ` struct tPacket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.