could enum be passed as argument ?

This is a discussion on could enum be passed as argument ? within the C++ Programming forums, part of the General Programming Boards category; I tried to pass some enum data as argument for function but failed, is it impossible ?...

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563

    Question could enum be passed as argument ?

    I tried to pass some enum data as argument for function but failed, is it impossible ?
    Never end on learning~

  2. #2
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Not at all

    enum BOOLEAN { TRUE, FALSE};
    int myfunction(BOOLEAN bValue);

    And to use it..

    BOOLEAN variable;
    variable = TRUE;

    myfunction(variable);

  3. #3
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Originally posted by Dual-Catfish
    Not at all

    enum BOOLEAN { TRUE, FALSE};
    int myfunction(BOOLEAN bValue);

    And to use it..

    BOOLEAN variable;
    variable = TRUE;

    myfunction(variable);
    woh~~~ it works!

    but it didnt in my constructor function. the code is right below, what's wrong ?
    PHP Code:
    enum GameKind{RPG,SLG,ACT,FTG,STG,SPG,RAC,ETC}; 
    class 
    Game
    {
      public:
        
    Game(){cout << "I have no arguments~ *o*" << endl;};
        
    Game(GameKindstringstringint);
      private:
        
    GameKind kind;
        
    string name;
        
    string company;
        
    int hot;
    };
    Game :: Game(GameKind kstring s1string s2int t)
    {
      
    cout << "I have some arguments~ ^o^" << endl

    Last edited by black; 06-27-2002 at 11:48 PM.
    Never end on learning~

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but it didnt in my constructor function
    The declaration and definition do not match up.

    -Prelude
    My best code is written with the delete key.

  5. #5
    flashing vampire black's Avatar
    Join Date
    May 2002
    Posts
    563
    Originally posted by Prelude
    >but it didnt in my constructor function
    The declaration and definition do not match up.

    -Prelude
    sorry~ now it is fixed. but it refused to work yet.
    Never end on learning~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Switch case and enum help
    By SomeCrazyGuy in forum C++ Programming
    Replies: 9
    Last Post: 04-21-2005, 08:53 PM
  4. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 08:45 PM
  5. how to check if a argument passed is integer
    By powinda in forum C Programming
    Replies: 7
    Last Post: 03-07-2004, 04:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21