From: Chris on
hi, if i have a local variable as
A a;

in a class. I declare it in header and define/intialize it in the cpp file,
normally.

If I declare it as a global variable in my project, will that be initialized
at the point of declaraion?
thanks
From: Scott McPhillips [MVP] on
"Chris" <Chris(a)discussions.microsoft.com> wrote in message
news:CF9AE349-20A1-4126-A798-982D5702D08D(a)microsoft.com...
> hi, if i have a local variable as
> A a;
>
> in a class. I declare it in header and define/intialize it in the cpp
> file,
> normally.
>
> If I declare it as a global variable in my project, will that be
> initialized
> at the point of declaraion?
> thanks

Yes, globals are initialized before main or WinMain are called.


--
Scott McPhillips [VC++ MVP]

From: David Wilkinson on
Chris wrote:
> hi, if i have a local variable as
> A a;
>
> in a class. I declare it in header and define/intialize it in the cpp file,
> normally.
>
> If I declare it as a global variable in my project, will that be initialized
> at the point of declaraion?

Chris:

What do you mean by "local variable in a class"?

Non-static (instance) member variable?

or

Static member variable?

Instance member variables are initialized with the object instance.

Static member variables are much like globals. As Scott says, they are
initialized before main() is entered.

--
David Wilkinson
Visual C++ MVP