F
fl
Hi,
When I search enum usage, I find the following example below. I find
that the definition:
inline Card::Suit operator++( Card::Suit &rs, int )
is interesting to me. What is the second parameter int for? Could you
tell me? Thanks.
..................................
// enumeration_declarations.cpp
class Card
{
public:
enum Suit
{
Diamonds,
Hearts,
Clubs,
Spades
};
// Declare two constructors: a default constructor,
// and a constructor that sets the cardinal and
// suit value of the new card.
Card();
Card( int CardInit, Suit SuitInit );
// Get and Set functions.
int GetCardinal(); // Get cardinal value of card.
int SetCardinal(); // Set cardinal value of card.
Suit GetSuit(); // Get suit of card.
void SetSuit(Suit new_suit); // Set suit of card.
char *NameOf(); // Get string representation of card.
private:
Suit suit;
int cardinalValue;
};
// Define a postfix increment operator for Suit.
inline Card::Suit operator++( Card::Suit &rs, int )
{
return rs = (Card::Suit)(rs + 1);
}
int main()
{
}
When I search enum usage, I find the following example below. I find
that the definition:
inline Card::Suit operator++( Card::Suit &rs, int )
is interesting to me. What is the second parameter int for? Could you
tell me? Thanks.
..................................
// enumeration_declarations.cpp
class Card
{
public:
enum Suit
{
Diamonds,
Hearts,
Clubs,
Spades
};
// Declare two constructors: a default constructor,
// and a constructor that sets the cardinal and
// suit value of the new card.
Card();
Card( int CardInit, Suit SuitInit );
// Get and Set functions.
int GetCardinal(); // Get cardinal value of card.
int SetCardinal(); // Set cardinal value of card.
Suit GetSuit(); // Get suit of card.
void SetSuit(Suit new_suit); // Set suit of card.
char *NameOf(); // Get string representation of card.
private:
Suit suit;
int cardinalValue;
};
// Define a postfix increment operator for Suit.
inline Card::Suit operator++( Card::Suit &rs, int )
{
return rs = (Card::Suit)(rs + 1);
}
int main()
{
}