#include "Str.h" // from lec11_code/str /* compile with: g++ -Wall -g -std=gnu++11 -c -o Init.o Init.cc */ class NoZero { public: NoZero(const Str& s) : s_(s) {}; private: Str s_; }; class Init { public: /* * Problems: * - Can't get in here since NoZero has * no zero-arg constructor. * - Default constructor is called * for s_, but contents of s_ are * immediately overwritten by * copy assignment. * Both of these problems can be fixed by using * an initialization list, like you see * in the constructor for NoZero. */ Init(const NoZero& nz, const Str& s) { nz_ = nz; s_ = s; } private: NoZero nz_; Str s_; };