Feb 25, 2010to initialize means assigning an initial state to the object before it is used. This initialization can be part of the instantiation process, in that case values are explicitly assigned to. } an important thing to remember:
At the moment you initialize even one object/variable in the struct, all of its other variables will be initialized to default value. If you don't initialize the values in your struct. How would you use memset to initialize a int array to some value larger than 255?
These are just a couple of examples where it isn't strictly necessary to initialize a variable, since it's set later (but not accessed between declaration and initialization). 0 other ways to initialize an object would be by using pipe (|) to define multiple types which is best if you expect the object to be filled out in the future say by a callback or rest call. Jan 11, 2010how to initialize hashset values by construction?
How to directly initialize a hashmap (in a literal way)? Feb 25, 2013i tried searching for this question through the search engine but could find a topic that explained the difference between initializing a class and instantiating an object. Oct 13, 2014a constructor should initialize an object in a way that it's in a usable state.
A constructor should only initialize an object, not perform heavy work. Oct 15, 2010how to initialize a struct in c# [duplicate] asked 15 years, 4 months ago modified 15 years, 4 months ago viewed 49k times