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++ conversion

int(n) and (int)n have exactly the same effect. But the C++-style int() syntax can only be used with types which have 'simple names' (I think this means eg int but not int *).

This explains btw why the mistaken use of

p = new int(n);

instead of

p = new int[n];

doesn't cause a warning or error: the compiler thinks you want a pointer to a new int, which int has been initialised with n.

Followers

Blog Archive