Thursday 14 May 2015

Some facts on C/C++

  1. Functions defined in a class are by default inline.
  2. Memory space for the members of a class is allocated when an object of that class is created, not before that(at declaration of the class).
  3. Compiler provides a zero argument constructor only when there is no other constructor defined in the class.
  4. Realloc can be used to reallocate the memory allocated using new operator.
  5. Size of the pointer does not depend on where it is pointing to, it is always the same.
  6. Copy constructor and assignment operators are provided by default by the compiler.
  7. When an object is passed or returned to/from a function by value the copy constructor gets called automatically.
  8. For a template function to work it is mandatory that its definition should always be present in the same file from where it is called.
  9. All static data members are initialized to zero.
  10. For every static data member of a class it should also be defined outside the class to allocate the storage location.

No comments:

Post a Comment