473,796 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scope resolution operator

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 ?
}
}

Jun 27 '08 #1
5 1651
In article <f7d55779-b634-4973-bd5d-
c3**********@u6 g2000prc.google groups.com>, sa***********@g mail.com
says...
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 ?
}
}
It's not possible unless the namespace in which SmeVar is located has a
name, which it doesn't in this case.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 27 '08 #2
On 6/2/2008 1:46 PM, Shan wrote:
In the following code:

func()
{
int SmeVar;
{
int& outer_SmeVar = SmeVar;
int SmeVar;
//Here I want to use SmeVar defined in the outer block how
can I do that ?
}
}
S.

--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Jun 27 '08 #3
On Jun 2, 5:15 pm, Stefan Naewe <nos...@please. netwrote:
On 6/2/2008 1:46 PM, Shan wrote:In the following code:
func()
{
int SmeVar;
{

int& outer_SmeVar = SmeVar;
int SmeVar;
//Here I want to use SmeVar defined in the outer block how
can I do that ?
}
}

S.

--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Hi,
Thanks for the reply, can you suggest any way of doing this using
scope resolution operator?
Jun 27 '08 #4
On 6/2/2008 2:24 PM, Shan wrote:
On Jun 2, 5:15 pm, Stefan Naewe <nos...@please. netwrote:
>On 6/2/2008 1:46 PM, Shan wrote:In the following code:
>>func()
{
int SmeVar;
{
int& outer_SmeVar = SmeVar;
>> int SmeVar;
//Here I want to use SmeVar defined in the outer block how
can I do that ?
}
}
S.
Hi,
Thanks for the reply, can you suggest any way of doing this using
scope resolution operator?
No.
Read what Jerry said. You need a named scope.

S.
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Jun 27 '08 #5
Shan wrote:
On Jun 2, 5:15 pm, Stefan Naewe <nos...@please. netwrote:
>On 6/2/2008 1:46 PM, Shan wrote:In the following code:
>>func()
{
int SmeVar;
{

int& outer_SmeVar = SmeVar;
>> int SmeVar;
//Here I want to use SmeVar defined in the outer block how
can I do that ?
}
}

S.

--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Hi,
Thanks for the reply, can you suggest any way of doing this using
scope resolution operator?
Sure. Give one of the variables a different name.

--
Jim Langston
ta*******@rocke tmail.com
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6479
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
2657
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
2094
by: Richard Hayden | last post by:
Hi, I have the following code for example: /**********************************/ #include <iostream> class C1 { public:
0
1101
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
3
4420
by: richard pickworth | last post by:
Hello :) I am familiar with using scope resolution operator to define classes, but why does it turn up elsewhere? thanks richard
16
1839
by: sushant | last post by:
hi , can we use scope resolution operator (::) in C??? sushant
6
5404
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
1
2585
by: Steven T. Hatton | last post by:
All of the following terms are used in some way to describe where and how a name is relevant to a particular location in a program: visible, declarative region, scope, potential scope, valid, introduced, used, potentially evaluated and accessible. They all seem to have subtle difference in meanings. Any positive contribution to the following will be appreciated. Here is my attempt to make sense of these:
2
1870
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 {};
0
9536
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10205
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
10021
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
9063
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5458
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
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
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
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.