Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Saturday, September 24, 2011

C++ constructor fumblings

Object a;

causes the constructor for Object to be called.

Object *pa;

does not (as I expected), but

pa = new Object;

does, which I suppose I also expected.

If it doesn't exist then the compiler gives up. Interestingly, gcc reports the constructors it does find, and I noticed that if I define no constructors at all for Object, then there is no complaint from the compiler, but if the only one I define is an unsuitable candidate, then gcc reports trying both my constructor and Object::Object(const Object&).

This is really confusing, it suggests that if no constructors are defined, then one for no arguments is created by default; but if one is defined, then a copy constructor is created by default??

Followers

Blog Archive