Professional-CPP-Source-Code

所属分类:Windows编程
开发工具:C++
文件大小:351KB
下载次数:3
上传日期:2013-07-30 21:18:54
上 传 者blackkettle
说明:  Professional C++, Second Edition by Marc Gregoire, Nicholas A. Solter, and Scott J. Kleper.的源代码
(source code distribution of examples in "Professional C++, Second Edition" by Marc Gregoire, Nicholas A. Solter, and Scott J. Kleper.)

文件列表:
SourceCodeProfessionalCppSecondEdition\932445c01_code\AirlineTicket\AirlineTicket.cpp (1277, 2011-04-12)
SourceCodeProfessionalCppSecondEdition\932445c01_code\AirlineTicket\AirlineTicket.h (597, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\AirlineTicket\AirlineTicketTest.cpp (1022, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\ConstArg\ConstArg.cpp (294, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\Database.cpp (2011, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\Database.h (613, 2010-07-21)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\DatabaseTest.cpp (724, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\Employee.cpp (1751, 2011-04-12)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\Employee.h (1116, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\EmployeeTest.cpp (414, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\EmployeeDB\UserInterface.cpp (2551, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\hellovariables\hellovariables.cpp (403, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\helloworld\helloworld.cpp (123, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\namespaces\namespaces.cpp (188, 2010-07-21)
SourceCodeProfessionalCppSecondEdition\932445c01_code\namespaces\namespaces.h (63, 2010-07-10)
SourceCodeProfessionalCppSecondEdition\932445c01_code\namespaces\usingnamespaces.cpp (148, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\std_array\std_array.cpp (242, 2011-10-28)
SourceCodeProfessionalCppSecondEdition\932445c01_code\stringtest\stringtest.cpp (219, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\stringtest2\stringtest2.cpp (490, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\StronglyTypedEnums\StronglyTypedEnums.cpp (212, 2010-08-07)
SourceCodeProfessionalCppSecondEdition\932445c01_code\structtest\employeestruct.h (177, 2010-07-10)
SourceCodeProfessionalCppSecondEdition\932445c01_code\structtest\structtest.cpp (686, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\typetest\typetest.cpp (424, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c01_code\vectortest\vectortest.cpp (708, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c06_code\Destructors\DestructorExamples.cpp (504, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c06_code\Destructors\DestructorHeapExamples.cpp (392, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c06_code\Destructors\SpreadsheetCell.cpp (1173, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\Destructors\SpreadsheetCell.h (510, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\InitializerListCtor\InitializerListCtor.cpp (873, 2011-04-17)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellAssign\SpreadsheetCell.cpp (1361, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellAssign\SpreadsheetCell.h (568, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellAssign\SpreadsheetCellAssignCopy.cpp (363, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellAssign\SpreadsheetCellTest.cpp (264, 2011-04-30)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellCopyCtor\SpreadsheetCell.cpp (1173, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellCopyCtor\SpreadsheetCell.h (510, 2010-07-31)
SourceCodeProfessionalCppSecondEdition\932445c06_code\SpreadsheetCellCopyCtor\SpreadsheetCellTest.cpp (307, 2011-04-30)
... ...

README for source code distribution of examples in "Professional C++, Second Edition" by Marc Gregoire, Nicholas A. Solter, and Scott J. Kleper. Unless otherwise noted, examples adhere to the C++ standard, so they should run with any standards-conforming compiler on any platform. Allmost all examples except those that use third-party libraries have been tested with g++ (GCC) 4.6 on Fedora 13, and Microsoft Visual C++ 2010 on Windows 7. Examples using third-party libraries or tools have been tested on a subset of the above platforms. The following C++11 features were not yet supported by GCC 4.6 at the time of this writing, so examples using those features have not been tested: - The final and override keyword - User defined literals - In-class non-static data member initialization - Template aliases - Delegating constructors - Inheriting constructors Microsoft Visual C++ 2010 supports less C++11 features compared to GCC 4.6. The online (www.wrox.com) Bonus Chapter 2 lists the C++11 features mentioned in this book and whether a compiler supports that feature. Compiling with g++ on Linux --------------------------- You can compile the examples that do not use third-party libraries with a simple command line: > g++ -o [source2.cpp ...] For example, you can compile the AirlineTicket example from Chapter 1 by changing to its directory and running: > g++ -std=c++0x -o AirlineTicket AirlineTicket.cpp AirlineTicketTest.cpp Now you can run the AirlineTicket program: > ./AirlineTicket The -std=c++0x is required to tell GCC to enable C++11 support. The parameter is c++0x, which was the working name during the standardization process of the new C++ standard. At the time of this writing, g++ still requires c++0x as parameter, and not yet c++11. Compiling with Visual Studio ---------------------------- Create a new project using the Visual C++ Win32 Console Project template. Enter a name and accept the defaults for each step of the wizard. Remove the files under "Source Files" and add the example files by dragging them onto "Source Files." Select "Start without Debugging" from the "Debug" menu to build and run the program. If you get an error similar to: "Unexpected end of file while looking for precompiled header directive" You need to turn off precompiled headers. Right click on the project in the Solution Explorer and select "Properties". Go to C/C++ Precompiled Headers and set the Create/Use Precompiled Header option to "Not Using Precompiled Headers". If your program exits before you have a chance to view the output, use the "Start without Debugging" menu item instead of the "Start" menu item. It will add a pause to the end of the program so you can view the output. Using Third-Party Libraries --------------------------- A few examples make use of third-party libraries discussed in the associated chapter, such as cppunit. To use those libraries, download them from the web site given in the text and build them according to the accompanying instructions. The README file with the library will usually describe how to use it. In most cases, you simply need to link the library or libraries when compiling. In g++, the command would look similar to this: g++ source.cpp -Lthirdparty/lib -Ithirdparty/include -lthirdparty The -L flag gives g++ a directory to search for additional libraries. The -I flag gives g++ a directory to look for user-defined headers, and the -l flag gives g++ the name of a library to link with. If the library file is libcppunit.so, for example, specify -lcppunit To run the program, you will need to put the compiled library in a system directory, or add it to the current user's dynamic library path as follows (assuming the bash shell): > export LD_LIBRARY_PATH=thirdparty/lib Then you will be able to run the program normally: > ./a.out

近期下载者

相关文件


收藏者