471,092 Members | 1,022 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 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 1481
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Anonymous | last post: by
5 posts views Thread by exits funnel | last post: by
7 posts views Thread by Richard Hayden | last post: by
reply views Thread by Howard Gardner | last post: by
3 posts views Thread by richard pickworth | last post: by
16 posts views Thread by sushant | last post: by
6 posts views Thread by Jack | last post: by
2 posts views Thread by xtrigger303 | last post: by

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.