Accessing functions from base class

Reply

Join Date: May 2004
Posts: 3
Reputation: dirs is an unknown quantity at this point 
Solved Threads: 0
dirs dirs is offline Offline
Newbie Poster

Accessing functions from base class

 
0
  #1
May 4th, 2004
Blackjack class is derived from card class ( see attached playingcard.h and blackjack.h)
I have problem with:
void blackjack:ealCards() 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???
Attached Files
File Type: cpp playingcards.cpp (7.8 KB, 28 views)
File Type: h playingcards.h (683 Bytes, 18 views)
File Type: h blackjack.h (417 Bytes, 18 views)
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 45
Reputation: BlackDice is an unknown quantity at this point 
Solved Threads: 0
BlackDice's Avatar
BlackDice BlackDice is offline Offline
Light Poster

Re: Accessing functions from base class

 
0
  #2
May 4th, 2004
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!!
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 3
Reputation: dirs is an unknown quantity at this point 
Solved Threads: 0
dirs dirs is offline Offline
Newbie Poster

Re: Accessing functions from base class

 
0
  #3
May 5th, 2004
Originally Posted by bdiamond
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!
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 45
Reputation: BlackDice is an unknown quantity at this point 
Solved Threads: 0
BlackDice's Avatar
BlackDice BlackDice is offline Offline
Light Poster

Re: Accessing functions from base class

 
0
  #4
May 5th, 2004
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:

Originally Posted by dirs
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!
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 3
Reputation: dirs is an unknown quantity at this point 
Solved Threads: 0
dirs dirs is offline Offline
Newbie Poster

Re: Accessing functions from base class

 
0
  #5
May 6th, 2004
Originally Posted by bdiamond
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!
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 45
Reputation: BlackDice is an unknown quantity at this point 
Solved Threads: 0
BlackDice's Avatar
BlackDice BlackDice is offline Offline
Light Poster

Re: Accessing functions from base class

 
0
  #6
May 6th, 2004
well try sending a pointer back of whatever type the array is then reference that pointer by a subscript



Originally Posted by dirs
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC