TITLE: Assignment is not initialization


[ This material adapted from "C++ Gotchas", tutorial notes by Tom Cargill,
  p. 16 ]


#include <stdio.h>


class C {
  public:
    C (const char*) { printf ("C::C(const char*)\n"); }
    C ()            { printf ("C::C()\n");            }
};

int main ()
{
    C x = "use constructor";
    printf ("--------------\n");

    C y;
    y = "make temp and assign\n";

    return 0;
}

This program will output the following:

    C::C (const char*)
    ------------------
    C::C()
    C::C(const char*)

For more information, see the ARM, p. 286.
