Consider the following header file, named Stringy.h: And, consider the following C++ file that contains main, named test_stringy.cc: Your job is to implement Stringy.cc, the C++ source file that goes along with Stringy.h. Once you have implemented it, you can compile and run test_string.cc as follows:
Notes:bash$ g++ -Wall -std=gnu++0x -g -o test_stringy Stringy.cc test_stringy.cc bash$ ./test_stringy Constructor(Test string!) ----- 1. string: Test string! Copy constructor(Test string!) ----- 2. upper string: TEST STRING! Destructor(TEST STRING!) Copy constructor(Test string!) Copy constructor(TEST STRING!) ----- 3. upper lower string: test string! Destructor(test string!) Destructor(TEST STRING!) Constructor() Copy constructor(Test string!) Move assign(test string!) Destructor(null) ----- 4. copy assigned copy: test string! Copy constructor(test string!) ----- 5. lower temporary: test string! Destructor(test string!) Copy assign(test string!) Destructor(test string!) Destructor(Test string!) bash$
- Some of this output comes from the mainline shown above, and some comes from output statements inserted in each of the methods you write so that we can see when they're invoked.
- The language allows the compiler to perform an optimization (return value optimization; see also [10.9] Does return-by-value mean extra copies and extra overhead?) that eliminates some constructor calls you might have expected.
- The output you see could be different if you use a different compiler or compiler version than what is loaded on CSE machines.
- We will grade your code by linking it with a grading mainline and examining the output. We are insensitive to whitespace when comparing output.
- It's intended that you have to look at the sample output above and match it to the sample mainline code to determine just what each of the methods you implement should print. (Note that one of the methods doesn't print anything in the sample. Follow the pattern of the others in that case.)