User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 392,004 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,159 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:

Variable scope problem

Join Date: Aug 2007
Posts: 48
Reputation: tonyaim83 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tonyaim83 tonyaim83 is offline Offline
Light Poster

Variable scope problem

  #1  
Sep 11th, 2007
Hi
I have the following code ...

main()
{
....
...
if(var==true)
{
Graph g1=CreateGraph<Graph>(vertex,edge);
}
else
{
Graph1 g1=CreateGraph<Graph1>(vertex,edge);
}

numvertex(g1);
}

When i m calling numvertex() function it says undefined identifier g1 what can be the solution for this. Provided I cannot make define the object globally or at the start of main(). Is there anyway out for this. I also tried making this static but no luck . Means the object scope ends as the If block ends.Plz help...
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 10:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC