In-depth C++
Books that go more deeply into topics of the language, and help you avoid the typical pitfalls inherent in developing C++ programs.
Large-Scale C++ Software Design, by John Lakos (Addison-Wesley, 1996). Motivates and presents in-the-trenches techniques for large C++ projects.
Effective C++, 2nd Edition, by Scott Meyers (Addison-Wesley, 1997). Classic book of techniques to improve C++ designs. Codifies many of the things that programmers have to learn the hard way.
More Effective C++, by Scott Meyers (Addison-Wesley, 1995) Continuation of Effective C++ (above). Another C++ classic.
Effective STL, by Scott Meyers (Addison-Wesley, 2001). Extremely practical, in-depth coverage of how to use the STL. Contains expert advice found nowhere else.
Generic Programming and the STL, by Matt Austern (Addison-Wesley, 1998). Explores the conceptual underpinnings of the design of the STL. Heavy on theory, but imparts a visionary look into the design of generic libraries.
Exceptional C++, by Herb Sutter (Addison-Wesley, 2000). Leads the reader through a progression of problems and their solution. Gives easy-to-remember advice for solid design of modern C++ programs.
More Exceptional C++, by Herb Sutter (Addison-Wesley, 2001). Continuation of Exceptional C++ (above).
C++ FAQs, 2nd Edition, by Marshall Cline, Greg Lomow, and Mike Girou (Addison-Wesley, 1998). Nicely-structured compendium of common C++ questions and their answers. Covers a broad range of topics, from beginner to advanced.
C++ Gotchas, by Stephen Dewhurst (Addison-Wesley, 2002). Contemporary catalog of easy-to-discover but hard-to-remedy C++ quirks by a widely-renowned recognized C++ expert.
C++ Templates, The Complete Guide, by David Vandervoorde and Nicolai M. Josuttis (Addison-Wesley, 2002). The first and only book devoted completely to templates. The definitive reference.
Standard C++ IOStreams and Locales, by Angelika Langer and Klaus Kreft (Addison-Wesley, 2000). The most in-depth coverage of iostreams available. Plumbs the depths of streams implementation and idiomatic use. A handy reference as well as tutorial.
Design & Evolution of C++, by Bjarne Stroustrup (Addison-Wesley, 1994). Traces the complete history of C++, documenting the design decisions that were made along the way. If you want to know why C++ is the way it is, this is the book with the answers, written by the designer of the language.
Modern C++ Design, by Andrei Alexandrescu (Addison-Wesley, 2001). The standard text on policy-based design in C++. Filled with practical, advanced uses of templates.
Generative Programming, by Krzysztof Czarnecki and Ulrich Eisencecker, (Addison-Wesley, 2000). Ground-breaking book on highly-advanced C++ techniques. Takes software automation to the next level.
Multi-Paradigm Design for C++, by James O. Coplien (Addison-Wesley, 1998). Advanced text showing how to harmonize the use of procedural, object-oriented, and generic programming for effective C++ designs.
Design Patterns
Design Patterns, by Erich Gamma et al (Addison-Wesley, 1995). The revolutionary book that introduced design patterns to the industry. Catalogs a critical of design patterns with motivation and examples (using C++ and a little SmallTalk).
Pattern-Oriented System Architecture, Volume 1: A System of Patterns, by Frank Buschmann et al (John Wiley & Son, 1996). Another look at design patterns in practice. Introduces new design patterns.
[ ]
B: Etc
This appendix contains files that are required to build the files in Volume 2.
//: :require.h
// Test for error conditions in programs
// Local "using namespace std" for old compilers
#ifndef REQUIRE_H
#define REQUIRE_H
#include <cstdio>
#include <cstdlib>
#include <fstream>
inline void require(bool requirement,
const char* msg = "Requirement failed") {
using namespace std;
if (!requirement) {
fputs(msg, stderr);
fputs("\n", stderr);
exit(EXIT_FAILURE);
}
}
inline void requireArgs(int argc, int args,
const char* msg = "Must use %d arguments") {
using namespace std;
if (argc != args + 1) {
fprintf(stderr, msg, args);
fputs("\n", stderr);
exit(EXIT_FAILURE);
}
}
inline void requireMinArgs(int argc, int minArgs,
const char* msg =
"Must use at least %d arguments") {
using namespace std;
if(argc < minArgs + 1) {
fprintf(stderr, msg, minArgs);
fputs("\n", stderr);
exit(EXIT_FAILURE);
}
}
inline void assure(std::ifstream& in,
const char* filename = "") {
using namespace std;
if(!in) {
fprintf(stderr,
"Could not open file %s\n", filename);
exit(EXIT_FAILURE);
}
}
inline void assure(std::ofstream& in,
const char* filename = "") {
using namespace std;
if(!in) {
fprintf(stderr,
"Could not open file %s\n", filename);
exit(EXIT_FAILURE);
}
}
inline void assure(std::fstream& in,
const char* filename = "") {
using namespace std;
if(!in) {
fprintf(stderr,
"Could not open file %s\n", filename);
exit(EXIT_FAILURE);
}
}
#endif // REQUIRE_H ///:~
//: C0B:Dummy.cpp
// To give the makefile at least one target
// for this directory
int main() {} ///:~
The Date class files:
//: C02:Date.h
#ifndef DATE_H
#define DATE_H
#include <string>
#include <stdexcept>
#include <iosfwd>
class Date {
public:
// A class for date calculations
struct Duration {
int years, months, days;
Duration(int y, int m, int d)
: years(y), months(m) ,days(d) {}
};
// An exception class
struct DateError : public std::logic_error {
DateError(const std::string& msg = "")
: std::logic_error(msg) {}
};
Date();
Date(int, int, int) throw(DateError);
Date(const std::string&) throw(DateError);
int getYear() const;
int getMonth() const;
int getDay() const;
std::string toString() const;
friend Duration duration(const Date&, const Date&);
friend bool operator<(const Date&, const Date&);
friend bool operator<=(const Date&, const Date&);
friend bool operator>(const Date&, const Date&);
friend bool operator>=(const Date&, const Date&);
friend bool operator==(const Date&, const Date&);
friend bool operator!=(const Date&, const Date&);
friend std::ostream& operator<<(std::ostream&,
const Date&);
friend std::istream& operator>>(std::istream&,
Date&);
private:
int year, month, day;
int compare(const Date&) const;
static int daysInPrevMonth(int year, int mon);
};