| | |
Need help with class constructor..
![]() |
•
•
Join Date: Nov 2008
Posts: 23
Reputation:
Solved Threads: 2
HEADER..
BODY
MAIN
Error:
prototype for `void Blackjack::InitDeck(Card*)' does not match any in class `Blackjack'
void Blackjack::InitDeck(Card*, int)
??
#include <string>
using std::string;
class Blackjack
{
public:
Blackjack(string);
void Shuffle();
void Intro(string);
void InitDeck(Card deck[],int numCards);
void PrintCard(int);
// void Card(int);
private:
int deck[52]; //deck of 52 cards.
};BODY
#include <iostream>
#include <fstream>
#include <cctype>
#include <cstdlib>
#include <ctime>
using namespace std;
const int NUM_CARDS = 52;
enum { Spades, Clubs, Hearts, Diamonds };
enum { JACK = 11, QUEEN, KING, ACE };
// type definitions
typedef int SuitType;
typedef int RankType;
typedef int ValueType;
// structure declarations
struct Card
{
SuitType suit;
RankType rank;
ValueType value;
};
#include "bj.h"
Blackjack::Blackjack(string name)
{
Intro( name );
}
void Blackjack::Intro(string name)
{
cout<<"##############################################################"<<endl;
cout<<"Program done by" << endl;
cout<<"Lets define the basic rules::" << endl;
cout<<"##############################################################"<<endl;
system("PAUSE");
void Blackjack::InitDeck(Card deck[] int numCards)//what each card is
{
auto int deckIndex = 0;
auto RankType rankCounter;
auto SuitType suitCounter;
for (suitCounter = Spades; suitCounter <= Diamonds; ++suitCounter)
{
for (rankCounter = 2; rankCounter <= ACE; ++rankCounter)
{
// set the suit and rank members
deck[deckIndex].suit = suitCounter;
deck[deckIndex].rank = rankCounter;
// set the value member
if (ACE == deck[deckIndex].rank)
{
// if we have an ace, assign the highest possible value
deck[deckIndex].value = 11;
}
else if (deck[deckIndex].rank >= JACK)
{
// if we have a face card, assign it a value of ten
deck[deckIndex].value = 10;
}
else
{
// the rank of the card is its value
deck[deckIndex].value = deck[deckIndex].rank;
}
++deckIndex;
}
}
} // end of "InitDeck"MAIN
#include<iostream>
#include "bj.h"
//-------------------------------------------------------------------
int main(int argc, char *argv[])
{
int numCards=0; //to know what card you are on
Blackjack myBlackjack("welcome to blackjack");
myBlackjack.Shuffle();
myBlackjack.PrintCard(0);
myBlackjack.InitDeck(deck[],52);
//myBlackjack.InitDeck();
system("\nPAUSE");
return 0;
}
//-------------------------------------------------------------------prototype for `void Blackjack::InitDeck(Card*)' does not match any in class `Blackjack'
void Blackjack::InitDeck(Card*, int)
??
Missing ',' huh....
see this..
see this..
c++ Syntax (Toggle Plain Text)
void Blackjack::InitDeck(Card deck[] int numCards) { //... }
•
•
Join Date: Nov 2008
Posts: 23
Reputation:
Solved Threads: 2
Ok i fixed that but now when i run main i get..
variable or field `InitDeck' declared void
'class Blackjack' has no member named 'InitDeck'
/facepalm
C++ Syntax (Toggle Plain Text)
#include<iostream> #include "bj.h" //------------------------------------------------------------------- int main(int argc, char *argv[]) { int numCards=0; //to know what card you are on int deck[52]; Blackjack myBlackjack("welcome to blackjack"); myBlackjack.Shuffle(); myBlackjack.PrintCard(0); myBlackjack.InitDeck(deck[],52); //myBlackjack.InitDeck(); system("\nPAUSE"); return 0; }
variable or field `InitDeck' declared void
'class Blackjack' has no member named 'InitDeck'
/facepalm
![]() |
Similar Threads
- How Do I . . . Make a Class Accessible from a DLL (C++)
- throwing statement in derived class constructor (C++)
- class constructor help (C#)
- Class Constructor Shorthand (C++)
- class rectangle (Java)
- Help : Pointers to array of class objects . (C++)
- Instantiating class objects?? (C++)
- Developing A Class (C++)
- 6 Line class -> Me pounding head into wall (C)
- '[Class] is not abstract..' error when i use 'implements' (Java)
Other Threads in the C++ Forum
- Previous Thread: Graph class in wxWidgets
- Next Thread: Help with Measurement converter
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ char class classes classified code coding compatible compile console conversion count date delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file filewrite forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper homeworksolutions iamthwee icon if...else ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node object output play pointer problem program programming project python random read recursion reference rpg string strings struct symbol temperature template test text text-file toolkit tree url values variable vector video win32 windows winsock wordfrequency wxwidgets





