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:
    http://www.daweidesigns.com
    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,374
    Likes Received:
    388
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice