Thread: Newbie Q? how do u turn bool functions off?!!

  1. #1
    rderiu
    Guest

    Newbie Q? how do u turn bool functions off?!!

    it sounds simple but everything i try doesnt work, im usin visuall c++

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Turning Boolean functions off? A bool function returns a bool
    value, you cant just give it a true or false value.
    as for a normal bool just
    Code:
     bool test; test=true; test=false;

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    >it sounds simple but everything i try doesnt work

    I think you have a function to turn something on and off, a toggle-function, which does not work as you expected. Maybe you could post your function and explain what it should do according to you.

  4. #4
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    I also think that you should post more explanations to your question...
    But I guess maybe you are asking about how to return a value for a bool function... If that's what you want it like this:
    Code:
    bool function(void)
    {
         return true;     //this returns true
                                 //or you can type return false; istead!
    }
    it's just as same as any other function except you can only return true of false!
    none...

  5. #5
    blah
    Guest
    Code:
    bool state;
    
    void myToggleFunc() {
         state = !state;
    }

  6. #6
    samurai warrior nextus's Avatar
    Join Date
    Nov 2001
    Posts
    196
    dont you mean
    Code:
    bool state; // i recommend initializing it..but if nots its automatically true (1)
    
    void myToggleFunc(bool& vstate)
    // since you are not returning anything you would want to 
    // pass this by reference to change the data
    {
         vstate = !vstate; // since state was true now state is false
    }
    i think that is what you mean
    nextus, the samurai warrior

  7. #7
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330

    ~

    I prefer to XOR bools with 1 to toggle em.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. BOOL bool ? unresolved external symbol
    By xwielder in forum C Programming
    Replies: 6
    Last Post: 05-20-2008, 08:39 AM
  3. Using private class members in static functions
    By sethjackson in forum C++ Programming
    Replies: 2
    Last Post: 09-23-2005, 09:54 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. help with classes and member functions
    By syner in forum C++ Programming
    Replies: 4
    Last Post: 07-19-2002, 08:45 PM