Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > What is the second parameter int for in a function declaration with enum

Reply
Thread Tools

What is the second parameter int for in a function declaration with enum

 
 
fl
Guest
Posts: n/a
 
      12-02-2011
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()
{
 
Reply With Quote
 
 
 
 
Pavel Volkovskiy
Guest
Posts: n/a
 
      12-02-2011
It is postfix operator (e.g. i++, while prefix operator (e.g. ++i
has operator++() signature.

http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
type declaration in declaration of a parameter or return type of a function Luca Forlizzi C Programming 4 11-14-2010 09:30 PM
Why does "template<typename T> ... function<T(int)>" not match "int(&)(int)" implicitly? Steve Hicks C++ 2 09-28-2009 05:24 PM
Using declaration inside first template parameter as default valuefor second template parameter. Stuart Redmann C++ 5 12-14-2007 08:42 AM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments