Global variable in c++.net 2003

  • Thread starter Thread starter Audwin
  • Start date Start date
A

Audwin

How to declare a global variable in c++.net 2003 ?
There is no something like module in c++.net .

Thanks
 
Just:
int FooInt = 2;
or, available within the project only:
static int FooInt = 2;

But obviously it would be better to declare as static variables within a
class.
--
David Anton
www.tangiblesoftwaresolutions.com
Convert between VB, C#, and C++
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
 
How to declare a global variable in c++.net 2003 ?

in your header declare the variable of your choosing
define it in one of your .cpp files.

..h extern int g_x;
..cpp int g_x = 1;

a better approach - if you really really need globals - is to put them
into a namespace:

namespace myglobals
{
int x;
};

...

cout << myglobals::x ;
 
Back
Top