Solved

Access Golbal var ?

Posted on 2000-04-11
3
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:rahul_asanikar
ID: 2556746
Adjusted points to 20
0
 
LVL 1

Accepted Solution

by:
Dhrubajyoti earned 20 total points
ID: 2710574
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
ID: 2744007
or use namespace...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

726 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