473,657 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

scope resolution operator

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
3 4406
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
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
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.co m> wrote in message
news:sl******** **********@pani x2.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6461
by: Anonymous | last post by:
Is namespace the same thing as scope? While reading the book "Thinking in C++", I was under the impression that namespace is, well, a namespace--a feature to create a hiearchy for identifiers within the Global Namespace. And that, all identifiers within a given namespace, however deeply nested they are, each of them has the Global Scope. So, if namespace outer { int a = 1;
5
2644
by: exits funnel | last post by:
Hello, I'm confused by the use of the Scope resolution operator on the indicated lines in the following code (which was copied from Thinking in C++ by Bruce Eckel). Removing them seems to have no effect. //Begin Code #include <new> // Size_t definition #include <fstream> using namespace std;
7
2087
by: Richard Hayden | last post by:
Hi, I have the following code for example: /**********************************/ #include <iostream> class C1 { public:
0
1091
by: Howard Gardner | last post by:
/* I don't have to provide scope resolution in sit 0 below: adl finds the function that I mean to use. I do have to provide scope resolution in sits 1 and 2. Can anyone teach me a trick to get around the need for scope resolution in sit 1 or sit 2? sit 1 is my motivating case, but if there's a trick for sit 2 I'd like
16
1823
by: sushant | last post by:
hi , can we use scope resolution operator (::) in C??? sushant
6
5396
by: Jack | last post by:
I want to write code that can be compiled as C and C++. In the Windows API, there are many macros that help with scope resolution. For example: #ifdef __cplusplus #define SNDMSG ::SendMessage #else #define SNDMSG SendMessage #endif
4
589
by: heng | last post by:
A::B I can understand that B is a member of the scope A But, sometimes I read the expression like ::C, what does this mean when the scope is absent? Thanks.
2
1862
by: xtrigger303 | last post by:
Hi to all, I was reading Mr. Alexandrescu's mojo article and I've a hard time understanding the following. Let's suppose I have: //code struct A {}; struct B : A {};
5
1641
by: Shan | last post by:
In the following code: func() { int SmeVar; { int SmeVar; //Here I want to use SmeVar defined in the outer block how can I do that ? }
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.