scope resolution operator

  • Thread starter richard pickworth
  • Start date
R

richard pickworth

Hello :)
I am familiar with using scope resolution operator to define classes, but
why does it turn up elsewhere?
thanks
richard
 
D

Donovan Rebbechi

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,
 
R

richard pickworth

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top