This tutorial was written in response to a lack of brief c++ textbooks. The emphasis is placed
upon brevity rather than completeness of information, assuming the reader can grasp the basic
structure of the language and then be able to expand upon the parts relevant to his/her project on
their own. A precursor to this tutorial is the C programming language. |
Textbooks generally can't be 'brief.' They
are books. That said a tutorial based on brevity rather than completeness of information and correctness isn't going to be of much help to anyone.
The "hello world" program won't compile.
std is not a library. Not all code in the namespace std is output oriented as it would seem to suggest. There is no mention of the caveats of using
using namespace std;
cout is not an instruction.
<< is not a sign.
string is not a keyword.
output to files is not done using the ifstream interface.
ifstream afile ("filename.txt");
does not open a file for i/o. It opens a file for input.
afile is then written to, which is wrong.
You use:
1 2 3
|
while (!afile.eof()) {
getline(afile, line);
}
|
as an example of how to read from a file, which is quite an error prone approach.
getgrade in the class example should be const.
student is not an object.
The section on constructors and destructors is very imprecise with wording. You don't even mention initializer lists. Tilde is spelled just so.
You introduce inheritance with a base class that has a variable for salary, and extend it with two classes that have additional variables for... salary, with a virtual function for setting the.. salary. Maybe something a little less contrived and more realistic is called for. We have enough bad examples of inheritance out there.
header files may not contain "Any construct you need". What may be included in a header file is quite a bit more restrictive than "throw in anything you need." .h files are not required to be in the same directory as .cpp files. .h files are not called.
virtual functions are not overriden by functions in the derived class with 'similar' names. The names must be identical.
setting static members of classes immediately after the class declaration is wrong. static members should be defined in the implementation file.
binary_search is used without indicating the container should be sorted.