Originally Posted by
coletek
Next time ya in a book store, just check it out, trust me it serves as a very awesome reference - its layout is terrific and reads very well. Half the book is a reference, which lists/compares operators, keywords, pre processor elements, library functions, io stream classes. And the other half of the book is a C++ tutorial. Trust me its really good - I've read (and flicked through) about 10 C++ books and found this to be the best.
Okay, using only that book as a reference, tell me what this program does without running it:
Code:
#include <map>
#include <string>
#include <cstddef>
#include <iostream>
int main()
{
using namespace std;
map<string, size_t> word_counts;
string word;
while (cin >> word)
{
++word_counts[word];
}
for (map<string, size_t>::iterator iter = word_counts.begin(), end = word_counts.end();
iter != end; ++iter)
{
cout << iter->first << ": " << iter->second << endl;
}
}
Originally Posted by
coletek
I come from a C world so, if you don't know C, then maybe this is not the book for you. But if you know C, this is the book for you.
According to Glassborow, the problem with this book is its content. The book teaches C++ as if it were merely a "better" C. Modern C++ puts the C++ standard library to good use and makes use of idioms that are not found in C. Apparently, despite being published years after the C++ Standard was ratified, the book even has examples that are pre-standard.
EDIT:
Actually, considering that Glassborow cited gets() and a failure to distinguish between a pointer and an array, it is conceivable that Overland does not even teach C++ as a "better" C in this book. (I actually stole that "better C" phrase from a customer review on Amazon.)