E
Ed Dana
You're my only hope!
OK, I gots a mystery on my hands. I'm hoping someone can tell me just
what the **** is going on here.
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. After writing some static
routines for Faces and Suits, I turned my attention to creating Cards
and Hands. Cards were no problem, Hands are starting to tick me off.
First, my header file for Hands:
======================================================================
#ifndef _Hand_H_
#define _Hand_H_
#include "Card.h"
class Hand {
public:
Hand();
bool add(Card prmCard);
bool canDouble();
bool canSplit();
int getSize();
int getValue();
bool isBlackjack();
bool isBusted();
bool isSoft();
void setHidden(int prmHideNo);
string toString();
string toString(bool prmLong);
private:
bool clsSoft;
int clsCount;
int clsHidden;
Card clsCards[0];
}
#endif //_Hand_H_
======================================================================
Next, my C++ file for Hands:
======================================================================
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
// Declarations...
#include "Hand.h"
// Definitions...
int clsCount;
int clsHidden;
bool clsSoft;
Card clsCards[0];
// Constructors...
Hand::Hand( ) {
}
// Methods...
.... All methods are currently stubs.
======================================================================
Please notice the "definitions" section. When compiled, it produces the
following error: "extraneous `int' ignored."
When I remove all definitions in that section, I get:
----------------------------------------------------------------------
12 Hand.cpp new types may not be defined in a return type
12 Hand.cpp return type specification for constructor invalid
----------------------------------------------------------------------
But when I change the definition section to remove the first, and only
first, int declaration, so that it looks like this:
======================================================================
// Definitions...
clsCount;
int clsHidden;
bool clsSoft;
Card clsCards[0];
======================================================================
It compiles successfully!
AND! More entertainingly! If I switch the declarations around so that
the bool is first, like this:
======================================================================
// Definitions...
bool clsSoft;
int clsCount;
int clsHidden;
Card clsCards[0];
======================================================================
I get the error: "'bool' is now a keyword." But, once again, like int,
leaving the bool keyword out compiles successfully.
What's going on?
I'm a C++ newbie, and I'm probably making some kinda C++ newbie mistake,
but because I a newbie, I've got no idea what that mistake might be.
I'm using DevCpp to compile this. Clues welcome.
Ed.
OK, I gots a mystery on my hands. I'm hoping someone can tell me just
what the **** is going on here.
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. After writing some static
routines for Faces and Suits, I turned my attention to creating Cards
and Hands. Cards were no problem, Hands are starting to tick me off.
First, my header file for Hands:
======================================================================
#ifndef _Hand_H_
#define _Hand_H_
#include "Card.h"
class Hand {
public:
Hand();
bool add(Card prmCard);
bool canDouble();
bool canSplit();
int getSize();
int getValue();
bool isBlackjack();
bool isBusted();
bool isSoft();
void setHidden(int prmHideNo);
string toString();
string toString(bool prmLong);
private:
bool clsSoft;
int clsCount;
int clsHidden;
Card clsCards[0];
}
#endif //_Hand_H_
======================================================================
Next, my C++ file for Hands:
======================================================================
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
// Declarations...
#include "Hand.h"
// Definitions...
int clsCount;
int clsHidden;
bool clsSoft;
Card clsCards[0];
// Constructors...
Hand::Hand( ) {
}
// Methods...
.... All methods are currently stubs.
======================================================================
Please notice the "definitions" section. When compiled, it produces the
following error: "extraneous `int' ignored."
When I remove all definitions in that section, I get:
----------------------------------------------------------------------
12 Hand.cpp new types may not be defined in a return type
12 Hand.cpp return type specification for constructor invalid
----------------------------------------------------------------------
But when I change the definition section to remove the first, and only
first, int declaration, so that it looks like this:
======================================================================
// Definitions...
clsCount;
int clsHidden;
bool clsSoft;
Card clsCards[0];
======================================================================
It compiles successfully!
AND! More entertainingly! If I switch the declarations around so that
the bool is first, like this:
======================================================================
// Definitions...
bool clsSoft;
int clsCount;
int clsHidden;
Card clsCards[0];
======================================================================
I get the error: "'bool' is now a keyword." But, once again, like int,
leaving the bool keyword out compiles successfully.
What's going on?
I'm a C++ newbie, and I'm probably making some kinda C++ newbie mistake,
but because I a newbie, I've got no idea what that mistake might be.
I'm using DevCpp to compile this. Clues welcome.
Ed.