473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 1615
In article <f7d55779-b634-4973-bd5d-
c3**********@u6g2000prc.googlegroups.com>, sa***********@gmail.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*******@rocketmail.com
Jun 27 '08 #6

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

Similar topics

3
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...
5
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...
7
by: Richard Hayden | last post by:
Hi, I have the following code for example: /**********************************/ #include <iostream> class C1 { public:
0
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...
3
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
by: sushant | last post by:
hi , can we use scope resolution operator (::) in C??? sushant
6
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...
1
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,...
2
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 {};
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.