#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    6
    Rep Power
    0

    c++ scope operator


    I am having difficulty understanding this piece of code.

    view.display(ClockView::civilian);

    the display function displays time in civilian or military format,

    what does ClockView::civilian do?

    Thanks.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,592
    Rep Power
    4207
    I'm guessing that civilian is a constant variable defined in the ClockView namespace. Please see using std namespace; what does it mean? for more about namespaces.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    USA
    Posts
    286
    Rep Power
    13
    My guess is that ClockView contains an enumeration specifying different values for civilian and military.

    Example:

    Code:
    class ClockView
    {
    ...
    public:
        enum
        {
            civilian = 0,
            military
        };
    ...
    };
    Then, in your display function, you can test the parameter to see if it == civilian (0) or military (1) by accessing the enumeration using the scope resolution operator as follows: ClockView::civilian or ClockView::military.

    More on the scope resolution operator
    Jon Sagara

    "Me fail English? That's unpossible!"

IMN logo majestic logo threadwatch logo seochat tools logo