Monday, December 12, 2011

[Cpp-Programming] Re: Inheritance and termination housekeeping

also note in these lines from above:

> int a; // declaration
> a = 42; // first assignment, or "initialisation" of a

I've written initialisation in quotes:

when you're thinking in terms of an object of type A the declaration
"A a;" would call the default constructor of A and thus actually
initialise the variable...
in a sense the default constructor of any base type is also
initialising the variable. that value is arbitrary, though: usually
the value in an "uninitialised" base type variable is whatever value
the allocated block of memory held before. again in terms of objects
you can think of this as the default constructor of base types.

when you're not using the constructor initialisation list for your
constructor, remember that all the members were initialised before you
enter the constructor body with their default constructor (this holds
true for actual class type members, your base classes and in the above
sense also for base type members). this is why your pointers will
usually not point to NULL but any arbitrary address - which you should
avoid categorically.

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

0 Comments:

Post a Comment

<< Home