#include #include #include #include #include #include using namespace std; #include "Example.h" // This code sends the bulk of its output to cerr, so // that the invoker can easily remove it (by redirecting, // as in ./example 2>/dev/null) int main(int argc, char* argv[]) { //---------------------------------------------------- // Aside: lvalues / rvalues // Here's an odd example of an l-value expression int i=0, j=0; (argc < 2 ? i : j) = 10; cerr << "i = " << i << " j = " << j << endl; //---------------------------------------------------- cerr << endl << "Construct ex" << endl; Example ex("main::ex"); // String constructor cerr << endl << "Construct mainResult" << endl; Example mainResult("main::mainResult"); // String constructor cerr << endl << "Construct final" << endl; Example final(mainResult.exampleFunc(ex)); // copy constructor(copy constructor) // Assignment operator invocations // copy assign cerr << endl << "Self-assignment statement:" << endl; mainResult = mainResult; // We have to be careful to handle this case correctly // possible move assign cerr << endl << "Function return assignment statement:" << endl; mainResult = mainResult.exampleFunc( mainResult ); // print invocation count results cout << endl << Example::countString() << endl; }