Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Access Golbal var ?

How can I access a global variable from a function which has same name as local variable in c++?
0
rahul_asanikar
Asked:
rahul_asanikar
1 Solution
 
rahul_asanikarAuthor Commented:
Adjusted points to 20
0
 
DhrubajyotiCommented:
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
 
WynCommented:
or use namespace...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now