Join Bill Weinman for an in-depth discussion in this video Exercise files, part of C++: Smart Pointers.
- The Exercise Files for this course are included with your basic Lynda.com membership. If you are a Lynda.com member, you have access to the Exercise Files used for this title. Copy the Exercise Files folder to a location where you can find it on your system. I copied it to the desktop on this system. Wherever you put it, just make sure you can find it. All of the Exercise Files for this course are in this folder. As you use each of these files, I suggest that you use a working copy so that you may easily revert back to the original if you need to.
This course requires a development environment with a C++11 or C++14 compliant compiler. I'm using a Mac with Xcode and Apple's excellent LLVM-based Compiler for the demonstrations in this course. You may just as easily use Windows or any other operating system with a C++11 compliant compiler. Please see my course C++ Essential Training for instructions on how to use these Exercise Files with either Xcode or Microsoft Visual Studio.
And here's the course on the Lynda.com website and these are the two movies that you're looking for. Using the Xcode with the exercises or using Microsoft Visual Studio with the exercises and this is the C++ Essential Training course. The exercises in this course use a common class called strc, and that's these two files here, strc.cpp and strc.h This is a simple string class with print statements for all the constructors and destructors.
Its purpose is to show how the smart pointers manage an object. In order to use these Exercise Files, you'll need to include the strc class in your project, as well as the current Exercise File. For example here on Xcode, I've copied the strc.cpp and .h from the Exercise Files into the Working project. Make sure to make a copy so that you don't lose the originals in the Exercise Files and I've also copied the current lesson example and when I build and run, it uses the strc class to display the constructors and destructor to show the life cycle of the object as it's using the smart pointers.
If you're on Windows using Microsoft Visual Studio, simply select the Working solution and Add, Existing Item. I'm just gonna make a Working copy of this shared_ptr.cpp. I'll hold down Control and drag it and it makes that copy and select Add. And now I have this example. I have my strc class already in there and I can select Build, F7, pressing F7 on the keyboard to build the current project and then I can switch over to my console and run Working and there's my example with all the constructors and destructors showing.
And then when I'm done with this Working copy, I simply delete it from the project and leave the strc class there for the next example. I'll be using Xcode for this course but you may of course use whatever environment you choose. The Exercise Files are here to make your learning experience easier and more powerful. Take your time, experiment a lot, and happy learning.