scope resolution operator

Discussion in 'C++' started by richard pickworth, Jun 5, 2005.

  1. Hello :)
    I am familiar with using scope resolution operator to define classes, but
    why does it turn up elsewhere?
    thanks
    richard
     
    richard pickworth, Jun 5, 2005
    #1
    1. Advertising

  2. richard pickworth

    Rapscallion Guest

    richard pickworth wrote:
    > I am familiar with using scope resolution operator to define classes, but
    > why does it turn up elsewhere?


    Where? Namespaces?
     
    Rapscallion, Jun 5, 2005
    #2
    1. Advertising

  3. On 2005-06-05, richard pickworth <> wrote:
    > Hello :)
    > I am familiar with using scope resolution operator to define classes, but
    > why does it turn up elsewhere?
    > thanks


    A few I can think of:
    (1) to call a static member function
    (2) to namespace-qualify something (e.g. std::cout << "hello" << std::endl; )
    (3) to explicitly call a base class member function instead of a derived class
    override, e.g.
    class Base { public: virtual void foo(); .... }
    class Derived : public Base {
    public:
    virtual void foo() {
    Base::foo();
    // do other stuff
    }
    };

    (4) to provide visibility for otherwise hidden methods via using (see the FAQ)
    e.g.
    class Base { public: void foo();
    }
    class Derived {
    public:
    void foo(int ); // hides base class version
    using Base::foo; // make it visible
    };

    that's all I can think of off the top of my head, but there could well be
    others I've left out.

    Cheers,
    --
    Donovan Rebbechi
    http://pegasus.rutgers.edu/~elflord/
     
    Donovan Rebbechi, Jun 5, 2005
    #3
  4. do you mean "static member function" i.e. as opposed to dynamicaly
    allocated?
    I thought you would use "class.function()".
    Dynamicaly, I thought maybe "class->function".
    Explicitly call a base class member function - that would fit with "scope
    resolution" maybe.
    I like your example on visibility. Do "virtual" functions belong in such
    situations, or similar? (I'm still trying to figure out polymorphism).
    using - I'm not familiar with this, except maybe "using namespace". I'll
    check out the FAQ if I can.
    Cheers
    Richard
    "Donovan Rebbechi" <> wrote in message
    news:...
    > On 2005-06-05, richard pickworth <>
    > wrote:
    >> Hello :)
    >> I am familiar with using scope resolution operator to define classes, but
    >> why does it turn up elsewhere?
    >> thanks

    >
    > A few I can think of:
    > (1) to call a static member function
    > (2) to namespace-qualify something (e.g. std::cout << "hello" <<
    > std::endl; )
    > (3) to explicitly call a base class member function instead of a derived
    > class
    > override, e.g.
    > class Base { public: virtual void foo(); .... }
    > class Derived : public Base {
    > public:
    > virtual void foo() {
    > Base::foo();
    > // do other stuff
    > }
    > };
    >
    > (4) to provide visibility for otherwise hidden methods via using (see the
    > FAQ)
    > e.g.
    > class Base { public: void foo();
    > }
    > class Derived {
    > public:
    > void foo(int ); // hides base class version
    > using Base::foo; // make it visible
    > };
    >
    > that's all I can think of off the top of my head, but there could well be
    > others I've left out.
    >
    > Cheers,
    > --
    > Donovan Rebbechi
    > http://pegasus.rutgers.edu/~elflord/
     
    richard pickworth, Aug 8, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. exits funnel

    Scope Resolution Operator

    exits funnel, Dec 12, 2003, in forum: C++
    Replies:
    5
    Views:
    557
    exits funnel
    Dec 13, 2003
  2. sushant

    scope resolution operator???????

    sushant, Jan 7, 2005, in forum: C Programming
    Replies:
    16
    Views:
    943
    Lawrence Kirby
    Jan 10, 2005
  3. Jack
    Replies:
    6
    Views:
    573
  4. dwaach
    Replies:
    1
    Views:
    410
    Victor Bazarov
    Jul 6, 2006
  5. heng

    scope resolution operator

    heng, Dec 6, 2006, in forum: C++
    Replies:
    4
    Views:
    391
    Default User
    Dec 6, 2006
Loading...

Share This Page