By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

scope resolution operator

P: n/a
Hello :)
I am familiar with using scope resolution operator to define classes, but
why does it turn up elsewhere?
thanks
richard
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


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


Where? Namespaces?

Jul 23 '05 #2

P: n/a
On 2005-06-05, richard pickworth <ri***************@btopenworld.com> 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/
Jul 23 '05 #3

P: n/a
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" <ab***@aol.com> wrote in message
news:sl******************@panix2.panix.com...
On 2005-06-05, richard pickworth <ri***************@btopenworld.com>
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/

Aug 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.