1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

what does ":" do in c++ code?

Discussion in 'C++' started by asilter, Sep 27, 2007.

  1. asilter

    asilter New Member

    Joined:
    Jul 31, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    i'm trying to read and understand a .cc (c++)file,
    i want to know what does ok_flag(false),time_range(false),prefix() do after ":" ?
    I did know that ":" was being used for class inheritance but what is ":" for in the bleow code?
    Code:
    ClassA::ClassA(const char *db) : ok_flag(false),time_range(false),prefix()
    {
    //.. Constructor statements
    }
    
    plz help
    thanx.
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    It initializes those variables in the class. It's more effective than putting statements inside the constructor.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    As far as I can remember its called initialization block.
     
  4. asilter

    asilter New Member

    Joined:
    Jul 31, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    ok,thanks.
     

Share This Page