Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
B.Eckel - Thinking in C++, Vol.2, 2nd edition.pdf
Скачиваний:
50
Добавлен:
08.05.2013
Размер:
2.09 Mб
Скачать

Large Scale C++ (?) by John Lakos.

C++ Gems, Stan Lippman, editor. SIGS publications.

The Design & Evolution of C++, by Bjarne Stroustrup

My own list of books

Not all of these are currently available.

Computer Interfacing with Pascal & C (Self-published via the Eisys imprint; only available via the Web site)

Using C++

C++ Inside & Out Thinking in C++, 1st edition

Black Belt C++, the Master’s Collection (edited by Bruce Eckel) (out of print). Thinking in Java, 2nd edition

Depth & dark corners

Books that go more deeply into topics of the language, and help you avoid the typical pitfalls inherent in developing C++ programs.

Effective C++ and More Effective C++, by Scott Meyers. Ruminations on C++ by Koenig & Moo.

The STL

Design Patterns

576

B: Etc

This appendix contains files from Volume 1 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(1);

}

}

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(1);

}

}

inline void requireMinArgs(int argc, int minArgs, const char* msg =

"Must use at least %d arguments") {

577

using namespace std; if(argc < minArgs + 1) {

fprintf(stderr, msg, minArgs); fputs("\n", stderr);

exit(1);

}

}

inline void assure(std::ifstream& in, const char* filename = "") {

using namespace std; if(!in) {

fprintf(stderr,

"Could not open file %s\n", filename); exit(1);

}

}

inline void assure(std::ofstream& in, const char* filename = "") {

using namespace std; if(!in) {

fprintf(stderr,

"Could not open file %s\n", filename); exit(1);

}

}

#endif // REQUIRE_H ///:~

From Volume 1, Chapter 9:

//: C0A:Stack4.h // With inlines #ifndef STACK4_H #define STACK4_H

#include "../require.h"

class Stack { struct Link {

void* data; Link* next;

Link(void* dat, Link* nxt): data(dat), next(nxt) {}

}* head;

578

public:

Stack(){ head = 0; } ~Stack(){

require(head == 0, "Stack not empty");

}

void push(void* dat) {

head = new Link(dat, head);

}

void* peek() { return head->data; } void* pop(){

if(head == 0) return 0; void* result = head->data; Link* oldHead = head;

head = head->next; delete oldHead; return result;

}

};

#endif // STACK4_H ///:~

//: C0A:Dummy.cpp

//To give the makefile at least one target

//for this directory

int main() {} ///:~

579

Соседние файлы в предмете Численные методы
  • #
    08.05.20133.99 Mб22A.Menezes, P.van Oorschot,S.Vanstone - HANDBOOK OF APPLIED CRYPTOGRAPHY.djvu
  • #
  • #
    08.05.20135.91 Mб24B.Eckel - Thinking in Java, 3rd edition (beta).pdf
  • #
  • #
    08.05.20136.09 Mб17D.MacKay - Information Theory, Inference, and Learning Algorithms.djvu
  • #
    08.05.20133.85 Mб15DIGITAL Visual Fortran ver.5.0 - Programmers Guide to Fortran.djvu
  • #
    08.05.20131.84 Mб12E.A.Lee, P.Varaiya - Structure and Interpretation of Signals and Systems.djvu