#include #include using namespace std; class MyClass { private: char * str; public: MyClass(const char *s) { cout << "String constructor: " << s << endl; str = strdup(s); } ~MyClass() { cout << "Destructor: " << str << endl; free(str); } MyClass(const MyClass &other) { cout << "Copy constructor" << endl; str = strdup(other.str); } const char *toString() const { return str; } }; int main(int argc, char *argv[]) { MyClass mc0("direct initialization"); MyClass mc1 = "copy initialization"; MyClass mc2 = {"list initialization"}; MyClass mc3{"another direct initialization"}; cout << endl; cout << mc0.toString() << endl << mc1.toString() << endl << mc2.toString() << endl << mc3.toString() << endl; cout << endl; /* Compiler errors this way be The value 280 can't be stored in 8 bits. char c0(280); // Warning char c1 = 280; // Warning char c2 = {280}; // Error char c3{280}; // Error */ return 0; }