Prev: VS: operator <<(...const std::string&) does not call ->rdbuf()
Next: Owner drawn listbox problem
From: Chris on 20 Nov 2009 14:10 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 20 Nov 2009 14:20 "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 20 Nov 2009 14:42 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
|
Pages: 1 Prev: VS: operator <<(...const std::string&) does not call ->rdbuf() Next: Owner drawn listbox problem |