Thinking in Cplus plus (P28) pptx
... }; int main() { vector<Trash*> bin; // Fill up the Trash bin: fillBin("Trash.dat", bin); TrashSorter tbins; tbins.push_back(new TrashBin<Aluminum>); tbins.push_back(new ... bins: bins.sortIntoBins(bin); TrashBinSet::iterator it; for(it = bins.begin(); it != bins.end(); it++) sumValue(**it); // and for the master bin sumValue(bin); purge(bin)...
Ngày tải lên: 05/07/2014, 19:20
... as a programming error. set_terminate( ) You can install your own terminate( ) function using the standard set_terminate( ) function, which returns a pointer to the terminate( ) function ... information about the error into a larger context by creating an object containing that information and “throwing” it out of your current context. This is called throwing an exception . Here’s...
Ngày tải lên: 05/07/2014, 19:20
... <iostream> using namespace std; class Singleton { int i; Singleton(int x) : i(x) { } void operator=(Singleton&); Singleton(const Singleton&); public: static Singleton& ... Identification 405 #include <cassert> #include <typeinfo> using namespace std; int main() { assert(typeid(47) == typeid(int)); assert(typeid(0) == typeid(int)); int...
Ngày tải lên: 05/07/2014, 19:20
Thinking in Cplus plus (P29) pot
... != string::npos || s.find(".TXT") != string::npos || s.find(".dat") != string::npos || s.find(".DAT") != string::npos) { // Text file, not involved in make ... makeFiles; while(getline (in, s)) { // Look for tag at beginning of line: if(s.find("//" ":") == 0 || s.find("/*" ":") == 0 || s.find("#&quo...
Ngày tải lên: 05/07/2014, 19:20
Thinking in Cplus plus (P30) pdf
... limits, 24 in- core formatting, 81 indexOf( ) , 485 inheritance and design patterns, 432 Appendix B: Programming Guidelines 551 value="cplusplus-email-list"> <input type="hidden" ... Appendix B: Programming Guidelines 557 continues(continue_str, ALEN(continue_str)); int main(int argc, char* argv[]) { requireArgs(argc, 2, "Usage:ExtractU...
Ngày tải lên: 05/07/2014, 19:20
Thinking in C plus plu (P5) pptx
... pointer to a function is defined and used: //: C03:PointerToFunction.cpp // Defining and using a pointer to a function #include <iostream> 194 Thinking in C++ www.BruceEckel.com circle ... project file , but the programming environment maintains this file so you don’t 198 Thinking in C++ www.BruceEckel.com int main() { ThreeDpoint p[10]; for(int i = 0; i < 10;...
Ngày tải lên: 05/07/2014, 19:20
Thinking in C plus plu (P6) pptx
... ifstream in( argv[1]); assure (in, argv[1]); Stack textlines; textlines.initialize(); string line; // Read file and store lines in the Stack: while(getline (in, line)) textlines.push(new ... containing a function f( ) that takes an int argument and prints it to the console using the printf( ) function in <stdio.h> by saying: printf(“%d\n”, i) in which...
Ngày tải lên: 05/07/2014, 19:20
Thinking in C plus plus (P8) pptx
... C08:EncapsulatingTypes.cpp #include <iostream> using namespace std; class Integer { int i; public: Integer(int ii = 0); void print(); }; Integer::Integer(int ii) : i(ii) {} void Integer::print() ... constants can be confusing. If 376 Thinking in C++ www.BruceEckel.com class B { int i; public: B(int ii); void print(); }; B::B(int ii) : i(ii) {} void B::...
Ngày tải lên: 05/07/2014, 19:20
Thinking in C plus plus (P15) pptx
... stack: while(getline (in, line)) textlines.push(new MyString(line)); // Pop some lines from the stack: MyString* s; for(int i = 0; i < 10; i++) { if((s=(MyString*)textlines.pop())==0) ... MyString: public string, public Object { public: ~MyString() { cout << "deleting string: " << *this << endl; } MyString(string s) : string(s) {} }; int...
Ngày tải lên: 05/07/2014, 19:20
Thinking in C plus plus(P17) pptx
... explicit casts · 167; casting away 794 Thinking in C++ www.BruceEckel.com argument list, etc., continuation lines should be indented one level in from the beginning of that definition, argument list, ... operating system was aware of upper and lower case in file names. The original file names were 800 Thinking in C++ www.BruceEckel.com 9. Don’t fall into analysis paralysis....
Ngày tải lên: 05/07/2014, 19:20