Solved

Access Golbal var ?

Posted on 2000-04-11
3
172 Views
Last Modified: 2010-04-02
How can I access a global variable from a function which has same name as local variable in c++?
0
Comment
Question by:rahul_asanikar
3 Comments
 

Author Comment

by:rahul_asanikar
Comment Utility
Adjusted points to 20
0
 
LVL 1

Accepted Solution

by:
Dhrubajyoti earned 20 total points
Comment Utility
use scope resolution operator.
eg try this
  my global variable name is test;

MyFunc()
{
   int test;
   ::test=5;//this will refer to
           //global variable
   test=7;//this will refer
            //    to local varable
   }
0
 
LVL 5

Expert Comment

by:Wyn
Comment Utility
or use namespace...
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now