Global variable in c++.net 2003

A

Audwin

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

Thanks
 
G

Guest

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
 
A

ajk

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 ;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top