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 9231449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:04:14+00:00 2026-06-18T06:04:14+00:00

I am trying to make a class that is a players hand (in a

  • 0

I am trying to make a class that is a players hand (in a card game for ex.). The draw method will draw another card, and showHand method should display the current cards in the hand. I have tried to initialize the array of pointers in the constructor, but am lost on how to do this (this is where I believe my issues stems from). trying the now commented out this->jon={}; gives this error: “error: incompatible types in assignment of ” to ‘Card* [12]'”

***currently when in showHand if I just try to cout jon[i]->getRank() a bunch of nonsense just pops up; however Draw method works perfectly.

class myHand{

public:

myHand(){
    this->size=0;
    //this->jon={};

}

void Draw(Card anyCard) {

    if(size>11) {
        cout<<"You can only have a maximum of 12 cards in your hand at a time"<<endl;
        return;
    }

    jon[size]=&anyCard;
    cout<<"HERE IS ANYCRD:"<<jon[size]->getRank()<<jon[size]->getSuit()<<endl;
    size++;
}

void showHand() {
   //DOESNT WORK HERE
}

void Place(Card* anyCard) {

}
private:
    int size;
    Card* jon[12];
};
  • 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-18T06:04:16+00:00Added an answer on June 18, 2026 at 6:04 am

    Your problem is dangling pointers.

    Your wider problem is in using pointers. Just don’t do that. Store an array of actual Card objects.

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

Sidebar

Related Questions

I am trying to make a class that will represent two different behaivours at
I'm trying to build a small class-like container that will make it a little
Hey I'm trying to make a Player class for my game that uses arrow
I'm trying to make a class that will handle some router functionality such as
I am trying to extend the mysqli class to make a helper class that
A am trying to make a program that takes a signal from one class
I'm trying to make spreadsheet with class/method modifiers. The spreadsheet itself can be located
I'm trying to make a small Flash game that has a GUI, which is
I created a game with timer, I am trying to make that when the
I'm trying to make a simple recursive function that will generate a list of

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.