Blackjack class is derived from card class ( see attached playingcard.h and blackjack.h)
I have problem with:
void blackjack::DealCards() function.
I want to use function deal_hands from card class to set the value of pcard1 pcard2, dcard1 and dcard2.
How could I do that???

Recommended Answers

All 5 Replies

You should be able to just type in CPlayingCard::deal_hands() (if CPlayingCard is the name of your base class), and that should be all there is to it!!

You should be able to just type in CPlayingCard::deal_hands() (if CPlayingCard is the name of your base class), and that should be all there is to it!!

Thanks for the reply!
The problem is that deal_hands function doesnt return anything at the moment.
Could it return an array of cards that could be used in the derrived class to set pcard1 , pcard2 etc.?
Thanks!

if there's an array for it in the base class, you should be able to access that array the same way CPlayingCard::array[1] (or whichever element you're looking for). Or you could have it return an array of cards by declaring the function return type as CCard*. Then just return the name of the array from the function as that will be a pointer to the first address, and a count of the cards, if it's possible for it to change. then you can iterate through each one as you need to up until the count returned. Hope this helps!!:mrgreen:

Thanks for the reply!
The problem is that deal_hands function doesnt return anything at the moment.
Could it return an array of cards that could be used in the derrived class to set pcard1 , pcard2 etc.?
Thanks!

if there's an array for it in the base class, you should be able to access that array the same way CPlayingCard::array[1] (or whichever element you're looking for). Or you could have it return an array of cards by declaring the function return type as CCard*. Then just return the name of the array from the function as that will be a pointer to the first address, and a count of the cards, if it's possible for it to change. then you can iterate through each one as you need to up until the count returned. Hope this helps!!:mrgreen:

I have tried to do like this CPlayingCard::array[1] but i get error
C:\cardgame\playingcards.cpp(154) : error C2275: 'blackjack::card' : illegal use of this type as an expression.
Thanks for reply!

well try sending a pointer back of whatever type the array is then reference that pointer by a subscript


I have tried to do like this CPlayingCard::array[1] but i get error
C:\cardgame\playingcards.cpp(154) : error C2275: 'blackjack::card' : illegal use of this type as an expression.
Thanks for reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.