E
Ed Dana
Greetings, all.
I'm familiar with other object oriented programming tools, such as Java
& REBOL. In an effort to become more familiar with C++, I decided to
write an object oriented BlackJack program. To begin with, I needed some
simple static routines for telling the value or suite of a face card.
So, I wrote the following C++ routine for Suites:
======================================================================
class Suite {
public:
static int getSuiteID(int prmCardID);
static char *getSuiteName(int prmCardID);
static char getShortName(int prmCardID);
static int main( );
Suite();
private:
static char *clsSuiteName[];
static int getSID(int prmCardID);
};
Suite::Suite( ) {
clsSuiteName[0] = "Hearts";
clsSuiteName[1] = "Clubs";
clsSuiteName[2] = "Diamonds";
clsSuiteName[3] = "Spades";
}
int Suite::getSID(int prmCardID) {
return prmCardID / 13;
}
int Suite::getSuiteID(int prmCardID) {
return getSID(prmCardID) + 1;
}
char *Suite::getSuiteName(int prmCardID) {
return clsSuiteName[ getSID( prmCardID ) ];
}
char Suite::getShortName(int prmCardID) {
return (char)getSuiteName(prmCardID);
}
======================================================================
Compiling this in M$ VC gives me the linker error: 'Suite.obj : error
LNK2001: unresolved external symbol "private: static char * *
Suite::clsSuiteName" (?clsSuiteName@Suite@@0PAPADA)'
Compiling it in wxDevC++ gives me a similar error: "[Linker error]
undefined reference to `Suite::clsSuiteName'"
I've tried everything I can think of to correct the problem, but at this
point, I ain't got a clue.
Any and all advice is welcome.
Ed.
I'm familiar with other object oriented programming tools, such as Java
& REBOL. In an effort to become more familiar with C++, I decided to
write an object oriented BlackJack program. To begin with, I needed some
simple static routines for telling the value or suite of a face card.
So, I wrote the following C++ routine for Suites:
======================================================================
class Suite {
public:
static int getSuiteID(int prmCardID);
static char *getSuiteName(int prmCardID);
static char getShortName(int prmCardID);
static int main( );
Suite();
private:
static char *clsSuiteName[];
static int getSID(int prmCardID);
};
Suite::Suite( ) {
clsSuiteName[0] = "Hearts";
clsSuiteName[1] = "Clubs";
clsSuiteName[2] = "Diamonds";
clsSuiteName[3] = "Spades";
}
int Suite::getSID(int prmCardID) {
return prmCardID / 13;
}
int Suite::getSuiteID(int prmCardID) {
return getSID(prmCardID) + 1;
}
char *Suite::getSuiteName(int prmCardID) {
return clsSuiteName[ getSID( prmCardID ) ];
}
char Suite::getShortName(int prmCardID) {
return (char)getSuiteName(prmCardID);
}
======================================================================
Compiling this in M$ VC gives me the linker error: 'Suite.obj : error
LNK2001: unresolved external symbol "private: static char * *
Suite::clsSuiteName" (?clsSuiteName@Suite@@0PAPADA)'
Compiling it in wxDevC++ gives me a similar error: "[Linker error]
undefined reference to `Suite::clsSuiteName'"
I've tried everything I can think of to correct the problem, but at this
point, I ain't got a clue.
Any and all advice is welcome.
Ed.