├── Chapter01
├── Car
│ ├── Car.cpp
│ ├── Car.h
│ ├── Car.vcxproj
│ ├── Car.vcxproj.filters
│ ├── Debug
│ │ └── Car.log
│ ├── Main.cpp
│ └── Release
│ │ ├── Car.Build.CppClean.log
│ │ └── Car.log
├── Dice
│ ├── Debug
│ │ └── Dice.log
│ ├── Dice.vcxproj
│ ├── Dice.vcxproj.filters
│ └── Main.cpp
├── Person
│ ├── Debug
│ │ └── Person.log
│ ├── Employee.cpp
│ ├── Employee.h
│ ├── Main.cpp
│ ├── Person.cpp
│ ├── Person.h
│ ├── Person.vcxproj
│ ├── Person.vcxproj.filters
│ ├── Release
│ │ ├── Person.Build.CppClean.log
│ │ └── Person.log
│ ├── Student.cpp
│ └── Student.h
├── Queue
│ ├── Cell.cpp
│ ├── Cell.h
│ ├── Debug
│ │ └── Queue.log
│ ├── Main.cpp
│ ├── Queue.cpp
│ ├── Queue.h
│ ├── Queue.vcxproj
│ ├── Queue.vcxproj.filters
│ └── Release
│ │ ├── Queue.Build.CppClean.log
│ │ └── Queue.log
└── Stack
│ ├── Cell.cpp
│ ├── Cell.h
│ ├── Debug
│ └── Stack.log
│ ├── Main.cpp
│ ├── Release
│ ├── Stack.Build.CppClean.log
│ └── Stack.log
│ ├── Stack.cpp
│ ├── Stack.h
│ ├── Stack.vcxproj
│ └── Stack.vcxproj.filters
├── Chapter02
├── ListAdvanced
│ ├── Debug
│ │ └── ListAdvanced.log
│ ├── List.h
│ ├── ListAdvanced.vcxproj
│ ├── ListAdvanced.vcxproj.filters
│ ├── Main.cpp
│ └── Release
│ │ ├── ListAdvanced.Build.CppClean.log
│ │ └── ListAdvanced.log
├── ListBasic
│ ├── Cell.cpp
│ ├── Cell.h
│ ├── Debug
│ │ └── ListBasic.log
│ ├── Iterator.cpp
│ ├── Iterator.h
│ ├── List.cpp
│ ├── List.h
│ ├── ListBasic.vcxproj
│ ├── ListBasic.vcxproj.filters
│ ├── Main.cpp
│ └── Release
│ │ ├── ListBasic.Build.CppClean.log
│ │ └── ListBasic.log
├── SearchAndSortAdvanced
│ ├── ArrayList.cpp
│ ├── ArrayList.h
│ ├── Debug
│ │ └── SearchAndSortAdvanced.log
│ ├── Main.cpp
│ ├── Release
│ │ ├── ArrayList.obj
│ │ ├── Main.obj
│ │ ├── SearchAn.18411F9B.tlog
│ │ │ ├── CL.read.1.tlog
│ │ │ ├── CL.write.1.tlog
│ │ │ ├── SearchAndSortAdvanced.lastbuildstate
│ │ │ ├── cl.command.1.tlog
│ │ │ ├── link.command.1.tlog
│ │ │ ├── link.read.1.tlog
│ │ │ └── link.write.1.tlog
│ │ ├── SearchAndSortAdvanced.log
│ │ └── vc120.pdb
│ ├── Search.h
│ ├── SearchAndSortAdvanced.vcxproj
│ ├── SearchAndSortAdvanced.vcxproj.filters
│ └── Sort.h
├── SearchAndSortBasic
│ ├── ArrayList.cpp
│ ├── ArrayList.h
│ ├── Debug
│ │ └── SearchAndSortBasic.log
│ ├── Main.cpp
│ ├── Search.cpp
│ ├── Search.h
│ ├── SearchAndSortBasic.vcxproj
│ ├── SearchAndSortBasic.vcxproj.filters
│ ├── Sort.cpp
│ └── Sort.h
├── SetAdvanced
│ ├── Debug
│ │ └── SetAdvanced.log
│ ├── Main.cpp
│ ├── Release
│ │ ├── SetAdvanced.Build.CppClean.log
│ │ └── SetAdvanced.log
│ ├── Set.h
│ ├── SetAdvanced.vcxproj
│ └── SetAdvanced.vcxproj.filters
└── SetBasic
│ ├── Debug
│ └── SetBasic.log
│ ├── Main.cpp
│ ├── Release
│ ├── SetBasic.Build.CppClean.log
│ └── SetBasic.log
│ ├── Set.cpp
│ ├── Set.h
│ ├── SetBasic.vcxproj
│ └── SetBasic.vcxproj.filters
├── Chapter03
└── LibraryBasic
│ ├── Book.cpp
│ ├── Book.h
│ ├── Customer.cpp
│ ├── Customer.h
│ ├── Debug
│ └── LibraryBasic.log
│ ├── Library.cpp
│ ├── Library.h
│ ├── LibraryBasic.vcxproj
│ ├── LibraryBasic.vcxproj.filters
│ └── Main.cpp
├── Chapter04
└── LibraryPointer
│ ├── Book.cpp
│ ├── Book.h
│ ├── Customer.cpp
│ ├── Customer.h
│ ├── Debug
│ └── LibraryPointer.log
│ ├── Library.cpp
│ ├── Library.h
│ ├── LibraryPointer.vcxproj
│ ├── LibraryPointer.vcxproj.filters
│ ├── Main.cpp
│ ├── Register.binary
│ └── Release
│ ├── LibraryPointer.Build.CppClean.log
│ └── LibraryPointer.log
├── Chapter05
├── ClockBasic
│ ├── Clock.cpp
│ ├── Clock.h
│ ├── ClockBasic.pro
│ ├── ClockBasic.pro.user
│ └── Main.cpp
├── DrawingBasic
│ ├── DrawingBasic.pro
│ ├── DrawingBasic.pro.user
│ ├── DrawingBasic.qrc
│ ├── DrawingWidget.cpp
│ ├── DrawingWidget.h
│ ├── DrawingWindow.cpp
│ ├── DrawingWindow.h
│ ├── Ellipse.cpp
│ ├── Ellipse.h
│ ├── Figure.cpp
│ ├── Figure.h
│ ├── Line.cpp
│ ├── Line.h
│ ├── Main.cpp
│ ├── Rectangle.cpp
│ ├── Rectangle.h
│ └── images
│ │ ├── center.png
│ │ ├── copy.png
│ │ ├── cut.png
│ │ ├── delete.png
│ │ ├── left.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── paste.png
│ │ ├── qt.png
│ │ ├── right.png
│ │ └── save.png
├── EditorBasic
│ ├── Caret.cpp
│ ├── Caret.h
│ ├── EditorBasic.pro
│ ├── EditorBasic.pro.user
│ ├── EditorBasic.qrc
│ ├── EditorWidget.cpp
│ ├── EditorWidget.h
│ ├── EditorWindow.cpp
│ ├── EditorWindow.h
│ ├── Main.cpp
│ └── images
│ │ ├── center.png
│ │ ├── copy.png
│ │ ├── cut.png
│ │ ├── left.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── paste.png
│ │ ├── qt.png
│ │ ├── right.png
│ │ └── save.png
└── MainWindow
│ ├── DocumentWidget.cpp
│ ├── DocumentWidget.h
│ ├── Listener.h
│ ├── MainWindow.cpp
│ └── MainWindow.h
├── Chapter06
├── ClockAdvanced
│ ├── Clock.cpp
│ ├── Clock.h
│ ├── ClockAdvanced.pro
│ ├── ClockAdvanced.pro.user
│ └── Main.cpp
├── DrawingAdvanced
│ ├── DrawingAdvanced.pro
│ ├── DrawingAdvanced.pro.user
│ ├── DrawingAdvanced.qrc
│ ├── DrawingWidget.cpp
│ ├── DrawingWidget.h
│ ├── DrawingWindow.cpp
│ ├── DrawingWindow.h
│ ├── Ellipse.cpp
│ ├── Ellipse.h
│ ├── Figure.cpp
│ ├── Figure.h
│ ├── Line.cpp
│ ├── Line.h
│ ├── Main.cpp
│ ├── Rectangle.cpp
│ ├── Rectangle.h
│ └── images
│ │ ├── center.png
│ │ ├── copy.png
│ │ ├── cut.png
│ │ ├── delete.png
│ │ ├── left.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── paste.png
│ │ ├── qt.png
│ │ ├── right.png
│ │ └── save.png
├── EditorAdvanced
│ ├── Caret.cpp
│ ├── Caret.h
│ ├── EditorAdvanced.pro
│ ├── EditorAdvanced.pro.user
│ ├── EditorAdvanced.qrc
│ ├── EditorWidget.cpp
│ ├── EditorWidget.h
│ ├── EditorWindow.cpp
│ ├── EditorWindow.h
│ ├── Main.cpp
│ └── images
│ │ ├── center.png
│ │ ├── copy.png
│ │ ├── cut.png
│ │ ├── left.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── paste.png
│ │ ├── qt.png
│ │ ├── right.png
│ │ └── save.png
└── MainWindow
│ ├── DocumentWidget.cpp
│ ├── DocumentWidget.h
│ ├── Listener.h
│ ├── MainWindow.cpp
│ └── MainWindow.h
├── Chapter07
├── MainWindow
│ ├── DocumentWidget.cpp
│ ├── DocumentWidget.h
│ ├── GameWidget.cpp
│ ├── GameWidget.h
│ ├── Listener.h
│ ├── MainWindow.cpp
│ └── MainWindow.h
├── NoughtsAndCrossesBasic
│ ├── Main.cpp
│ ├── NaCWidget.cpp
│ ├── NaCWidget.h
│ ├── NaCWindow.cpp
│ └── NaCWindow.h
└── OthelloBasic
│ ├── Main.cpp
│ ├── OthelloWidget.cpp
│ ├── OthelloWidget.h
│ ├── OthelloWindow.cpp
│ └── OthelloWindow.h
├── Chapter08
├── MainWindow
│ ├── DocumentWidget.cpp
│ ├── DocumentWidget.h
│ ├── GameWidget.cpp
│ ├── GameWidget.h
│ ├── Listener.h
│ ├── MainWindow.cpp
│ └── MainWindow.h
├── NoughtsAndCrossesAdvanced
│ ├── Main.cpp
│ ├── NaCWidget.cpp
│ ├── NaCWidget.h
│ ├── NaCWindow.cpp
│ └── NaCWindow.h
└── OthelloAdvanced
│ ├── Main.cpp
│ ├── OthelloWidget.cpp
│ ├── OthelloWidget.h
│ ├── OthelloWindow.cpp
│ └── OthelloWindow.h
├── Chapter09
├── Action.cpp
├── Action.h
├── Colors.cpp
├── Colors.h
├── Error.cpp
├── Error.h
├── Input.dsl
├── Main.cpp
├── Parser.cpp
├── Parser.h
├── Scanner.cpp
├── Scanner.h
├── Token.cpp
├── Token.h
├── Value.cpp
├── Value.h
├── ViewerWidget.cpp
└── ViewerWidget.h
├── Chapter10
├── Action.cpp
├── Action.h
├── Colors.cpp
├── Colors.h
├── Directive.cpp
├── Directive.h
├── Error.cpp
├── Error.h
├── Evaluator.cpp
├── Evaluator.h
├── Function.cpp
├── Function.h
├── Input.dsl
├── Main.cpp
├── Parser.cpp
├── Parser.h
├── Scanner.cpp
├── Scanner.h
├── Token.cpp
├── Token.h
├── Value.cpp
├── Value.h
├── ViewerWidget.cpp
└── ViewerWidget.h
├── LICENSE
└── README.md
/Chapter01/Car/Car.cpp:
--------------------------------------------------------------------------------
1 | #include "Car.h"
2 |
3 | Car::Car()
4 | :m_speed(0),
5 | m_direction(0) {
6 | // Empty.
7 | }
8 |
9 | Car::Car(int speed, int direction)
10 | :m_speed(speed),
11 | m_direction(direction) {
12 | // Empty.
13 | }
14 |
15 | Car::~Car() {
16 | // Empty.
17 | }
18 |
19 | int Car::getSpeed() const {
20 | return m_speed;
21 | }
22 |
23 | int Car::getDirection() const {
24 | return m_direction;
25 | }
26 |
27 | void Car::accelerate(int speed) {
28 | m_speed += speed;
29 | }
30 |
31 | void Car::decelerate(int speed) {
32 | m_speed -= speed;
33 | }
34 |
35 | void Car::turnLeft(int degrees) {
36 | m_direction -= degrees;
37 | }
38 |
39 | void Car::turnRight(int degrees) {
40 | m_direction += degrees;
41 | }
42 |
--------------------------------------------------------------------------------
/Chapter01/Car/Car.h:
--------------------------------------------------------------------------------
1 | class Car {
2 | public:
3 | Car();
4 | Car(int speed, int direction);
5 |
6 | int getSpeed() const;
7 | int getDirection() const;
8 |
9 | void accelerate(int speed);
10 | void decelerate(int speed);
11 |
12 | void turnLeft(int degrees);
13 | void turnRight(int degrees);
14 |
15 | ~Car();
16 |
17 | private:
18 | int m_speed, m_direction;
19 | };
--------------------------------------------------------------------------------
/Chapter01/Car/Car.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Source Files
16 |
17 |
18 | Source Files
19 |
20 |
21 |
22 |
23 | Header Files
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Chapter01/Car/Debug/Car.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:54.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.02
6 |
--------------------------------------------------------------------------------
/Chapter01/Car/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 | #include "Car.h"
4 |
5 | void main() {
6 | Car redVolvo;
7 | cout << "Red Volvo Speed: " << redVolvo.getSpeed() << " miles/hour"
8 | << ", Direction: " << redVolvo.getDirection() << " degrees" << endl;
9 |
10 | redVolvo.accelerate(30);
11 | redVolvo.turnRight(30);
12 | cout << "Red Volvo Speed: " << redVolvo.getSpeed() << " miles/hour"
13 | << ", Direction: " << redVolvo.getDirection() << " degrees" << endl;
14 |
15 | redVolvo.decelerate(10);
16 | redVolvo.turnLeft(10);
17 | cout << "Red Volvo Speed: " << redVolvo.getSpeed() << " miles/hour"
18 | << ", Direction: " << redVolvo.getDirection() << " degrees" << endl;
19 |
20 | const Car blueFiat(100, 90);
21 | cout << "Blue Fiat Speed: " << blueFiat.getSpeed() << " miles/hour"
22 | << ", Direction: " << blueFiat.getDirection() << " degrees"
23 | << endl;
24 | }
25 |
--------------------------------------------------------------------------------
/Chapter01/Car/Release/Car.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\main.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\car.exe
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\car.pdb
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\cl.command.1.tlog
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\cl.read.1.tlog
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\cl.write.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\link.command.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\link.read.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\car\release\car.tlog\link.write.1.tlog
12 |
--------------------------------------------------------------------------------
/Chapter01/Car/Release/Car.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:31.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.03
6 |
--------------------------------------------------------------------------------
/Chapter01/Dice/Debug/Dice.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:49.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.30
6 |
--------------------------------------------------------------------------------
/Chapter01/Dice/Dice.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Chapter01/Dice/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | void main() {
7 | srand((int) time(nullptr));
8 | int dice = (rand() % 6 ) + 1;
9 | cout << "Dice: " << dice << endl;
10 | }
--------------------------------------------------------------------------------
/Chapter01/Person/Debug/Person.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:54.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter01/Person/Employee.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "Person.h"
6 | #include "Employee.h"
7 |
8 | Employee::Employee(string name, string company)
9 | :Person(name),
10 | m_company(company) {
11 | // Empty.
12 | }
13 |
14 | void Employee::print() {
15 | Person::print();
16 | cout << "Company " << m_company << endl;
17 | }
--------------------------------------------------------------------------------
/Chapter01/Person/Employee.h:
--------------------------------------------------------------------------------
1 | class Employee : public Person {
2 | public:
3 | Employee(string name, string company);
4 | void print();
5 |
6 | private:
7 | string m_company;
8 | };
--------------------------------------------------------------------------------
/Chapter01/Person/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "Person.h"
6 | #include "Student.h"
7 | #include "Employee.h"
8 |
9 | void main() {
10 | Person person("Monica");
11 | person.print();
12 | cout << endl;
13 |
14 | Student student("Demi", "Harvard");
15 | student.print();
16 | cout << endl;
17 |
18 | Employee employee("Charles", "Microsoft");
19 | employee.print();
20 | cout << endl;
21 |
22 | Person* personPtr;
23 | personPtr = &person;
24 | personPtr->print();
25 | cout << endl;
26 |
27 | personPtr = &student;
28 | personPtr->print();
29 | cout << endl;
30 |
31 | personPtr = &employee;
32 | personPtr->print();
33 | }
--------------------------------------------------------------------------------
/Chapter01/Person/Person.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "Person.h"
6 |
7 | Person::Person(string name)
8 | :m_name(name) {
9 | // Empty.
10 | }
11 |
12 | void Person::print() {
13 | cout << "Person " << m_name << endl;
14 | }
--------------------------------------------------------------------------------
/Chapter01/Person/Person.h:
--------------------------------------------------------------------------------
1 | class Person {
2 | public:
3 | Person(string name);
4 | virtual void print();
5 |
6 | private:
7 | string m_name;
8 | };
--------------------------------------------------------------------------------
/Chapter01/Person/Person.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 |
14 |
15 | Header Files
16 |
17 |
18 | Header Files
19 |
20 |
21 | Header Files
22 |
23 |
24 |
25 |
26 | Source Files
27 |
28 |
29 | Source Files
30 |
31 |
32 | Source Files
33 |
34 |
35 | Source Files
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Chapter01/Person/Release/Person.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\student.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\main.obj
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\employee.obj
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\person.exe
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\person.pdb
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\cl.command.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\cl.read.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\cl.write.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\link.command.1.tlog
12 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\link.read.1.tlog
13 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\person\release\person.tlog\link.write.1.tlog
14 |
--------------------------------------------------------------------------------
/Chapter01/Person/Release/Person.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:31.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00
6 |
--------------------------------------------------------------------------------
/Chapter01/Person/Student.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "Person.h"
6 | #include "Student.h"
7 |
8 | Student::Student(string name, string university)
9 | :Person(name),
10 | m_university(university) {
11 | // Empty.
12 | }
13 |
14 | void Student::print() {
15 | Person::print();
16 | cout << "University " << m_university << endl;
17 | }
--------------------------------------------------------------------------------
/Chapter01/Person/Student.h:
--------------------------------------------------------------------------------
1 | class Student : public Person {
2 | public:
3 | Student(string name, string university);
4 | void print();
5 |
6 | private:
7 | string m_university;
8 | };
--------------------------------------------------------------------------------
/Chapter01/Queue/Cell.cpp:
--------------------------------------------------------------------------------
1 | #include "Cell.h"
2 |
3 | Cell::Cell(int value, Cell* next)
4 | :m_value(value),
5 | m_next(next) {
6 | // Empty.
7 | }
--------------------------------------------------------------------------------
/Chapter01/Queue/Cell.h:
--------------------------------------------------------------------------------
1 | class Cell {
2 | public:
3 | Cell(int value, Cell* next);
4 | int value() const {return m_value;}
5 | Cell* getNext() const { return m_next; }
6 | void setNext(Cell* next) { m_next = next; }
7 |
8 | private:
9 | int m_value;
10 | Cell* m_next;
11 | };
12 |
--------------------------------------------------------------------------------
/Chapter01/Queue/Debug/Queue.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:51.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter01/Queue/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | #include "Cell.h"
7 | #include "Queue.h"
8 |
9 | void main() {
10 | Queue q;
11 | q.enter(1);
12 | q.enter(2);
13 | q.enter(3);
14 | cout << "first " << q.first() << ", size " << q.size()
15 | << ", empty " << (q.empty() ? "true" : "false") << endl;
16 |
17 | q.remove();
18 | q.remove();
19 | q.enter(4);
20 | cout << "first " << q.first() << ", size " << q.size()
21 | << ", empty " << (q.empty() ? "true" : "false") << endl;
22 | }
--------------------------------------------------------------------------------
/Chapter01/Queue/Queue.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | #include "Cell.h"
5 | #include "Queue.h"
6 |
7 | Queue::Queue()
8 | :m_firstCellPtr(nullptr),
9 | m_lastCellPtr(nullptr),
10 | m_size(0) {
11 | // Empty.
12 | }
13 |
14 | void Queue::enter(int value) {
15 | Cell *newCellPtr = new Cell(value, nullptr);
16 | assert(newCellPtr != nullptr);
17 |
18 | if (empty()) {
19 | m_firstCellPtr = m_lastCellPtr = newCellPtr;
20 | }
21 | else {
22 | m_lastCellPtr->setNext(newCellPtr);
23 | m_lastCellPtr = newCellPtr;
24 | }
25 |
26 | ++m_size;
27 | }
28 |
29 | int Queue::first() {
30 | assert(!empty());
31 | return m_firstCellPtr->value();
32 | }
33 |
34 | void Queue::remove() {
35 | assert(!empty());
36 | Cell* deleteCellPtr = m_firstCellPtr;
37 | m_firstCellPtr = m_firstCellPtr->getNext();
38 | delete deleteCellPtr;
39 | --m_size;
40 | }
41 |
42 | int Queue::size() const {
43 | return m_size;
44 | }
45 |
46 | bool Queue::empty() const {
47 | return (m_firstCellPtr == nullptr);
48 | }
--------------------------------------------------------------------------------
/Chapter01/Queue/Queue.h:
--------------------------------------------------------------------------------
1 | class Queue {
2 | public:
3 | Queue();
4 | void enter(int value);
5 | int first();
6 | void remove();
7 | int size() const;
8 | bool empty() const;
9 |
10 | private:
11 | Cell *m_firstCellPtr, *m_lastCellPtr;
12 | int m_size;
13 | };
--------------------------------------------------------------------------------
/Chapter01/Queue/Queue.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Chapter01/Queue/Release/Queue.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\main.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\cell.obj
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\queue.exe
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\queue.pdb
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\cl.command.1.tlog
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\cl.read.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\cl.write.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\link.command.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\link.read.1.tlog
12 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\queue\release\queue.tlog\link.write.1.tlog
13 |
--------------------------------------------------------------------------------
/Chapter01/Queue/Release/Queue.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:28.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00
6 |
--------------------------------------------------------------------------------
/Chapter01/Stack/Cell.cpp:
--------------------------------------------------------------------------------
1 | #include "Cell.h"
2 |
3 | Cell::Cell(int value, Cell* next)
4 | :m_value(value),
5 | m_next(next) {
6 | // Empty.
7 | }
--------------------------------------------------------------------------------
/Chapter01/Stack/Cell.h:
--------------------------------------------------------------------------------
1 | class Cell {
2 | public:
3 | Cell(int value, Cell* next);
4 | int getValue() const {return m_value;}
5 | Cell* getNext() const {return m_next;}
6 |
7 | private:
8 | int m_value;
9 | Cell* m_next;
10 | };
--------------------------------------------------------------------------------
/Chapter01/Stack/Debug/Stack.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:51.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter01/Stack/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "Cell.h"
6 | #include "Stack.h"
7 |
8 | void main() {
9 | Stack s;
10 | s.push(1);
11 | s.push(2);
12 | s.push(3);
13 | cout << "top " << s.top() << ", size " << s.size()
14 | << ", empty " << (s.empty() ? "true" : "false") << endl;
15 |
16 | s.pop();
17 | s.pop();
18 | s.push(4);
19 | cout << "top " << s.top() << ", size " << s.size()
20 | << ", empty " << (s.empty() ? "true" : "false") << endl;
21 | }
--------------------------------------------------------------------------------
/Chapter01/Stack/Release/Stack.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\main.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\cell.obj
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\stack.exe
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\stack.pdb
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\cl.command.1.tlog
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\cl.read.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\cl.write.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\link.command.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\link.read.1.tlog
12 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\stack\release\stack.tlog\link.write.1.tlog
13 |
--------------------------------------------------------------------------------
/Chapter01/Stack/Release/Stack.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:28.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter01/Stack/Stack.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | #include "Cell.h"
5 | #include "Stack.h"
6 | Stack::Stack()
7 | :m_firstCellPtr(nullptr),
8 | m_size(0) {
9 | // Empty.
10 | }
11 |
12 | void Stack::push(int value) {
13 | m_firstCellPtr = new Cell(value, m_firstCellPtr);
14 | assert(m_firstCellPtr != nullptr);
15 | ++m_size;
16 | }
17 |
18 | int Stack::top() {
19 | assert(!empty());
20 | return m_firstCellPtr->getValue();
21 | }
22 |
23 | void Stack::pop() {
24 | assert(!empty());
25 | Cell* deleteCellPtr = m_firstCellPtr;
26 | m_firstCellPtr = m_firstCellPtr->getNext();
27 | delete deleteCellPtr;
28 | --m_size;
29 | }
30 |
31 | int Stack::size() const {
32 | return m_size;
33 | }
34 |
35 | bool Stack::empty() const {
36 | return (m_firstCellPtr == nullptr);
37 | }
--------------------------------------------------------------------------------
/Chapter01/Stack/Stack.h:
--------------------------------------------------------------------------------
1 | class Stack {
2 | public:
3 | Stack();
4 | void push(int value);
5 | int top();
6 | void pop();
7 | int size() const;
8 | bool empty() const;
9 |
10 | private:
11 | Cell* m_firstCellPtr;
12 | int m_size;
13 | };
14 |
--------------------------------------------------------------------------------
/Chapter01/Stack/Stack.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Chapter02/ListAdvanced/Debug/ListAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:51.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.02
6 |
--------------------------------------------------------------------------------
/Chapter02/ListAdvanced/ListAdvanced.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Chapter02/ListAdvanced/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "List.h"
6 |
7 | void main() {
8 | LinkedList list;
9 | cin >> list;
10 | cout << list << endl;
11 |
12 | for (double value : list) {
13 | cout << value << " ";
14 | }
15 | cout << endl;
16 |
17 | for (LinkedList::Iterator iterator = list.begin();
18 | iterator != list.end(); ++iterator) {
19 | cout << *iterator << " ";
20 | }
21 | cout << endl;
22 |
23 | for (LinkedList::ReverseIterator iterator =
24 | list.rbegin(); iterator != list.rend(); ++iterator) {
25 | cout << *iterator << " ";
26 | }
27 | cout << endl;
28 | }
--------------------------------------------------------------------------------
/Chapter02/ListAdvanced/Release/ListAdvanced.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\main.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\listadvanced.exe
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\listadvanced.pdb
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\cl.command.1.tlog
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\cl.read.1.tlog
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\cl.write.1.tlog
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\link.command.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\link.read.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listadvanced\release\listadvanced.tlog\link.write.1.tlog
11 |
--------------------------------------------------------------------------------
/Chapter02/ListAdvanced/Release/ListAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:28.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Cell.cpp:
--------------------------------------------------------------------------------
1 | #include "Cell.h"
2 |
3 | Cell::Cell(double value, Cell* previous, Cell* next)
4 | :m_value(value),
5 | m_previous(previous),
6 | m_next(next) {
7 | // Empty.
8 | }
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Cell.h:
--------------------------------------------------------------------------------
1 | class Cell {
2 | private:
3 | Cell(double value, Cell* previous, Cell* next);
4 | friend class LinkedList;
5 |
6 | public:
7 | double getValue() const { return m_value; }
8 | void setValue(double value) { m_value = value; }
9 |
10 | Cell* getPrevious() const { return m_previous; }
11 | void setPrevious(Cell* previous) { m_previous = previous; }
12 |
13 | Cell* getNext() const { return m_next; }
14 | void setNext(Cell* getNext) { m_next = getNext; }
15 |
16 | private:
17 | double m_value;
18 | Cell* m_previous;
19 | Cell* m_next;
20 | };
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Debug/ListBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:51.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Iterator.cpp:
--------------------------------------------------------------------------------
1 | #include "Cell.h"
2 | #include "Iterator.h"
3 |
4 | Iterator::Iterator(Cell* cellPtr)
5 | :m_cellPtr(cellPtr) {
6 | // Empty.
7 | }
8 |
9 | Iterator::Iterator()
10 | :m_cellPtr(nullptr) {
11 | // Empty.
12 | }
13 |
14 | Iterator::Iterator(const Iterator& iterator)
15 | :m_cellPtr(iterator.m_cellPtr) {
16 | // Empty.
17 | }
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Iterator.h:
--------------------------------------------------------------------------------
1 | class Iterator {
2 | private:
3 | Iterator(Cell* cellPtr);
4 |
5 | public:
6 | Iterator();
7 | Iterator(const Iterator& iterator);
8 |
9 | double getValue() { return m_cellPtr->getValue(); }
10 | void setValue(double value) { m_cellPtr->setValue(value); }
11 |
12 | bool hasNext() const { return (m_cellPtr != nullptr); }
13 | void next() { m_cellPtr = m_cellPtr->getNext(); }
14 |
15 | bool hasPrevious() const { return (m_cellPtr != nullptr); }
16 | void previous() { m_cellPtr = m_cellPtr->getPrevious(); }
17 |
18 | friend class LinkedList;
19 |
20 | private:
21 | Cell* m_cellPtr;
22 | };
23 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/List.h:
--------------------------------------------------------------------------------
1 | class LinkedList {
2 | public:
3 | LinkedList();
4 | LinkedList(const LinkedList& list);
5 | void assign(const LinkedList& list);
6 | ~LinkedList();
7 |
8 | int size() const {return m_size;}
9 | bool empty() const {return (m_size == 0);}
10 | bool find(double value, Iterator& findIterator);
11 |
12 | bool equal(const LinkedList& list) const;
13 | bool notEqual(const LinkedList& list) const;
14 |
15 | void add(double value);
16 | void add(const LinkedList& list);
17 |
18 | void insert(const Iterator& insertPosition, double value);
19 | void insert(const Iterator& insertPosition,
20 | const LinkedList& list);
21 |
22 | void erase(const Iterator& erasePosition);
23 | void remove(const Iterator& firstPosition,
24 | const Iterator& lastPosition = Iterator(nullptr));
25 | void clear();
26 |
27 | Iterator first() const { return Iterator(m_firstCellPtr); }
28 | Iterator last() const { return Iterator(m_lastCellPtr); }
29 |
30 | void read(istream& inStream);
31 | void write(ostream& outStream);
32 |
33 | private:
34 | int m_size;
35 | Cell* m_firstCellPtr;
36 | Cell* m_lastCellPtr;
37 | };
38 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/ListBasic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | #include "Cell.h"
5 | #include "Iterator.h"
6 | #include "List.h"
7 |
8 | void main() {
9 | LinkedList list;
10 | list.add(1);
11 | list.add(2);
12 | list.add(3);
13 | list.add(4);
14 | list.add(5);
15 | list.write(cout);
16 | cout << endl;
17 |
18 | { Iterator iterator = list.first();
19 | while (iterator.hasNext()) {
20 | cout << iterator.getValue() << " ";
21 | iterator.next();
22 | }
23 | cout << endl;
24 | }
25 |
26 | { Iterator iterator = list.last();
27 | while (iterator.hasPrevious()) {
28 | cout << iterator.getValue() << " ";
29 | iterator.previous();
30 | }
31 | cout << endl;
32 | }
33 | }
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Release/ListBasic.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\main.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\list.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\iterator.obj
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\cell.obj
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\listbasic.exe
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\listbasic.pdb
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\cl.command.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\cl.read.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\cl.write.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\link.command.1.tlog
12 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\link.read.1.tlog
13 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\listbasic\release\listbasic.tlog\link.write.1.tlog
14 |
--------------------------------------------------------------------------------
/Chapter02/ListBasic/Release/ListBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:28.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Debug/SearchAndSortAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:52.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.06
6 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/ArrayList.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/ArrayList.obj
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/Main.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/Main.obj
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/CL.read.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/CL.write.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/SearchAndSortAdvanced.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
2 | Release|Win32|C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\|
3 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/cl.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/cl.command.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.command.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.read.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/SearchAn.18411F9B.tlog/link.write.1.tlog
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/SearchAndSortAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:29:56.
2 | 1>Project "C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\SearchAndSortAdvanced\SearchAndSortAdvanced.vcxproj" on node 2 (Build target(s)).
3 | 1>ClCompile:
4 | C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Release\\" /Fd"Release\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt ArrayList.cpp Main.cpp
5 | ArrayList.cpp
6 | Main.cpp
7 | Link:
8 | C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\Release\SearchAndSortAdvanced.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\Release\SearchAndSortAdvanced.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\Release\SearchAndSortAdvanced.lib" /MACHINE:X86 /SAFESEH Release\ArrayList.obj
9 | Release\Main.obj
10 | Generating code
11 | Finished generating code
12 | SearchAndSortAdvanced.vcxproj -> C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\Release\SearchAndSortAdvanced.exe
13 | 1>Done Building Project "C:\Users\Stefan\Documents\A A_Cpp_By_Example\CppByExample\SearchAndSortAdvanced\SearchAndSortAdvanced.vcxproj" (Build target(s)).
14 |
15 | Build succeeded.
16 |
17 | Time Elapsed 00:00:01.65
18 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Release/vc120.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/CPP17-By-Example/543f6cc865b8fe5fb83dd5886c73e5dff45f377f/Chapter02/SearchAndSortAdvanced/Release/vc120.pdb
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/Search.h:
--------------------------------------------------------------------------------
1 | template
2 | int linarySearch(const ValueType& value, const ListType& list) {
3 | int index = 0;
4 |
5 | for (double listValue : list) {
6 | if (listValue == value) {
7 | return index;
8 | }
9 |
10 | ++index;
11 | }
12 |
13 | return -1;
14 | }
15 |
16 | template
17 | int binarySearch(const ValueType& value, const ListType& list) {
18 | ListType::Iterator* positionBuffer =
19 | new ListType::Iterator[list.size()];
20 |
21 | int index = 0;
22 | for (ListType::Iterator position = list.begin();
23 | position != list.end(); ++position) {
24 | positionBuffer[index++] = position;
25 | }
26 |
27 | int minIndex = 0, maxIndex = list.size() - 1;
28 |
29 | while (minIndex <= maxIndex) {
30 | int middleIndex = (maxIndex + minIndex) / 2;
31 | ListType::Iterator iterator = positionBuffer[middleIndex];
32 | const ValueType& middleValue = *iterator;
33 |
34 | if (value == middleValue) {
35 | return middleIndex;
36 | }
37 | else if (value < middleValue) {
38 | maxIndex = middleIndex - 1;
39 | }
40 | else {
41 | minIndex = middleIndex + 1;
42 | }
43 | }
44 |
45 | return -1;
46 | }
47 |
48 | /*template
49 | int linarySearch(const ValueType& value, const ListType& list) {
50 | for (int index = 0; index < list.size(); ++index) {
51 | if (list[index] == value) {
52 | return index;
53 | }
54 | }
55 |
56 | return -1;
57 | }
58 |
59 | template
60 | int binarySearch(const ValueType& value, const ListType& list) {
61 | int minIndex = 0, maxIndex = list.size() - 1;
62 |
63 | while (minIndex <= maxIndex) {
64 | int middleIndex = (maxIndex + minIndex) / 2;
65 | const ValueType& middleValue = list[middleIndex];
66 |
67 | if (value == middleValue) {
68 | return middleIndex;
69 | }
70 | else if (value < middleValue) {
71 | maxIndex = middleIndex - 1;
72 | }
73 | else {
74 | minIndex = middleIndex + 1;
75 | }
76 | }
77 |
78 | return -1;
79 | }*/
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortAdvanced/SearchAndSortAdvanced.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortBasic/Debug/SearchAndSortBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:53.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.02
6 |
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortBasic/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | using namespace std;
5 |
6 | #include "..\\ListBasic\\Cell.h"
7 | #include "..\\ListBasic\\Iterator.h"
8 | #include "..\\ListBasic\\List.h"
9 |
10 | #include "Search.h"
11 | #include "Sort.h"
12 |
13 | void main() {
14 | cout << "LinkedList" << endl;
15 |
16 | LinkedList list;
17 | list.add(9);
18 | list.add(7);
19 | list.add(5);
20 | list.add(3);
21 | list.add(1);
22 |
23 | list.write(cout);
24 | cout << endl;
25 |
26 | Iterator iterator = list.first();
27 | while (iterator.hasNext()) {
28 | cout << "<" << iterator.getValue() << ","
29 | << linarySearch(iterator.getValue(), list) << "> ";
30 | iterator.next();
31 | }
32 |
33 | cout << "<0," << linarySearch(0, list) << "> ";
34 | cout << "<6," << linarySearch(6, list) << "> ";
35 | cout << "<10," << linarySearch(10, list) << ">"
36 | << endl;
37 |
38 | cout << "Bubble Sort ";
39 | bubbleSort(list);
40 | list.write(cout);
41 | cout << endl;
42 |
43 | cout << "Select Sort ";
44 | selectSort(list);
45 | list.write(cout);
46 | cout << endl;
47 |
48 | cout << "Insert Sort ";
49 | insertSort(list);
50 | list.write(cout);
51 | cout << endl;
52 | }
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortBasic/Search.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace std;
3 |
4 | #include "..\\ListBasic\\Cell.h"
5 | #include "..\\ListBasic\\Iterator.h"
6 | #include "..\\ListBasic\\List.h"
7 | #include "Search.h"
8 |
9 | int linarySearch(double value, const LinkedList& list) {
10 | int index = 0;
11 | Iterator iterator = list.first();
12 |
13 | while (iterator.hasNext()) {
14 | if (iterator.getValue() == value) {
15 | return index;
16 | }
17 |
18 | ++index;
19 | iterator.next();
20 | }
21 |
22 | return -1;
23 | }
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortBasic/Search.h:
--------------------------------------------------------------------------------
1 | int linarySearch(double value, const LinkedList& list);
2 |
3 | /*template
4 | int linarySearch(const ValueType& value, const ListType& list) {
5 | int index = 0;
6 |
7 | for (Iterator iterator = list.first(); iterator.hasNext(); iterator.next()) {
8 | if (iterator.getValue() == value) {
9 | return index;
10 | }
11 |
12 | ++index;
13 | }
14 |
15 | return -1;
16 | }*/
--------------------------------------------------------------------------------
/Chapter02/SearchAndSortBasic/SearchAndSortBasic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Header Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 | Header Files
58 |
59 |
60 |
--------------------------------------------------------------------------------
/Chapter02/SetAdvanced/Debug/SetAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:52.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter02/SetAdvanced/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "..\\ListAdvanced\\List.h"
6 | #include "Set.h"
7 |
8 | void main() {
9 | Set s, t;
10 | cin >> s >> t;
11 |
12 | cout << endl << "s: " << s << endl;
13 | cout << "t: " << t << endl;
14 |
15 | cout << endl << "s: ";
16 | for (double value : s) {
17 | cout << value << " ";
18 | }
19 |
20 | cout << endl << "t: ";
21 | for (Set::Iterator iterator = t.begin();
22 | iterator != t.end(); ++iterator) {
23 | cout << *iterator << " ";
24 | }
25 |
26 | cout << endl << endl << "union: " << (s + t) << endl;
27 | cout << "intersection: " << (s *t) << endl;
28 | cout << "difference: " << (s - t) << endl << endl;
29 | }
--------------------------------------------------------------------------------
/Chapter02/SetAdvanced/Release/SetAdvanced.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\main.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\setadvanced.exe
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\setadvanced.pdb
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\cl.command.1.tlog
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\cl.read.1.tlog
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\cl.write.1.tlog
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\link.command.1.tlog
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\link.read.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setadvanced\release\setadvanced.tlog\link.write.1.tlog
11 |
--------------------------------------------------------------------------------
/Chapter02/SetAdvanced/Release/SetAdvanced.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:29.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00
6 |
--------------------------------------------------------------------------------
/Chapter02/SetAdvanced/SetAdvanced.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Chapter02/SetBasic/Debug/SetBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:52.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.03
6 |
--------------------------------------------------------------------------------
/Chapter02/SetBasic/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | using namespace std;
4 |
5 | #include "..\\ListBasic\\Cell.h"
6 | #include "..\\ListBasic\\Iterator.h"
7 | #include "..\\ListBasic\\List.h"
8 | #include "Set.h"
9 |
10 | void main() {
11 | Set s, t;
12 | s.read(cin);
13 | t.read(cin);
14 |
15 | cout << endl << "s = ";
16 | s.write(cout);
17 | cout << endl;
18 |
19 | cout << endl << "t = ";
20 | t.write(cout);
21 | cout << endl << endl;
22 |
23 | cout << "union: ";
24 | unionSet(s, t).write(cout);
25 | cout << endl;
26 |
27 | cout << "intersection: ";
28 | unionSet(s, t).write(cout);
29 | cout << endl;
30 |
31 | cout << "difference: ";
32 | unionSet(s, t).write(cout);
33 | cout << endl;
34 | }
--------------------------------------------------------------------------------
/Chapter02/SetBasic/Release/SetBasic.Build.CppClean.log:
--------------------------------------------------------------------------------
1 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\vc120.pdb
2 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\set.obj
3 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\main.obj
4 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\list.obj
5 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\iterator.obj
6 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\cell.obj
7 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\setbasic.exe
8 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\release\setbasic.pdb
9 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\cl.command.1.tlog
10 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\cl.read.1.tlog
11 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\cl.write.1.tlog
12 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\link.command.1.tlog
13 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\link.read.1.tlog
14 | c:\users\stefan\documents\a a_cpp_by_example\cppbyexample\setbasic\release\setbasic.tlog\link.write.1.tlog
15 |
--------------------------------------------------------------------------------
/Chapter02/SetBasic/Release/SetBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-06-29 17:45:30.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter02/SetBasic/Set.h:
--------------------------------------------------------------------------------
1 | class Set : private LinkedList {
2 | public:
3 | Set();
4 | Set(double value);
5 | Set(const Set& set);
6 | void assign(const Set& set);
7 | ~Set();
8 |
9 | bool equal(const Set& set) const;
10 | bool notEqual(const Set& set) const;
11 |
12 | bool exists(double value) const;
13 | bool exists(const Set& set) const;
14 |
15 | bool insert(double value);
16 | bool insert(const Set& set);
17 |
18 | bool remove(double value);
19 | bool remove(const Set& set);
20 |
21 | int size() const { return LinkedList::size(); }
22 | bool empty() const { return LinkedList::empty(); }
23 | Iterator first() const { return LinkedList::first(); }
24 |
25 | friend Set unionSet(const Set& leftSet, const Set& rightSet);
26 | friend Set intersection(const Set& leftSet,
27 | const Set& rightSet);
28 | friend Set difference(const Set& leftSet,
29 | const Set& rightSet);
30 |
31 | void read(istream& inStream);
32 | void write(ostream& outStream);
33 | };
34 |
--------------------------------------------------------------------------------
/Chapter02/SetBasic/SetBasic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/Book.h:
--------------------------------------------------------------------------------
1 | class Book {
2 | public:
3 | Book(void);
4 | Book(const string& author, const string& title);
5 |
6 | // Book(const Book& book);
7 | // Book& operator=(const Book& book);
8 |
9 | void read(ifstream& inStream);
10 | void write(ofstream& outStream) const;
11 |
12 | void borrowBook(int customerId);
13 | void returnBook();
14 | int reserveBook(int customerId);
15 | void unreserveBook(int customerId);
16 |
17 | int bookId(void) const { return m_bookId; }
18 | bool borrowed(void) const { return m_borrowed; }
19 | int customerId(void) const { return m_customerId; }
20 |
21 | list& reservList(void) { return m_reservationList; }
22 | const string& author(void) const { return m_author; }
23 | const string& title(void) const { return m_title; }
24 |
25 | static int MaxBookId;
26 | friend ostream& operator<<(ostream& outStream,
27 | const Book& book);
28 |
29 | private:
30 | bool m_borrowed = false;
31 | int m_bookId, m_customerId;
32 | string m_author, m_title;
33 | list m_reservationList;
34 | };
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/Customer.h:
--------------------------------------------------------------------------------
1 | class Customer {
2 | public:
3 | Customer(void);
4 | Customer(const string& name, const string& address);
5 |
6 | //Customer(const Customer& customer);
7 | //Customer& operator=(const Customer& customer);
8 |
9 | void read(ifstream& inStream);
10 | void write(ofstream& outStream) const;
11 |
12 | void borrowBook(int bookId);
13 | void returnBook(int bookId);
14 | void reserveBook(int bookId);
15 | void unreserveBook(int bookId);
16 |
17 | bool hasBorrowed(void) const { return !m_loanSet.empty(); }
18 |
19 | const string& name(void) const {return m_name;}
20 | const string& address(void) const { return m_address; }
21 | int id(void) const { return m_customerId; }
22 |
23 | static int MaxCustomerId;
24 | friend ostream& operator<<(ostream& outStream,
25 | const Customer& customer);
26 |
27 | private:
28 | int m_customerId;
29 | string m_name, m_address;
30 | set m_loanSet, m_reservationSet;
31 | };
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/Debug/LibraryBasic.log:
--------------------------------------------------------------------------------
1 | Build started 2017-12-01 15:26:50.
2 |
3 | Build succeeded.
4 |
5 | Time Elapsed 00:00:00.01
6 |
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/Library.h:
--------------------------------------------------------------------------------
1 | class Library {
2 | public:
3 | Library();
4 |
5 | private:
6 | static string s_binaryPath;
7 |
8 | bool lookupBook(const string& author, const string& title,
9 | Book* bookPtr = nullptr);
10 | bool lookupCustomer(const string& name, const string& address,
11 | Customer* customerPtr = nullptr);
12 |
13 | void addBook(void);
14 | void deleteBook(void);
15 | void listBooks(void);
16 | void addCustomer(void);
17 | void deleteCustomer(void);
18 | void listCustomers(void);
19 | void borrowBook(void);
20 | void reserveBook(void);
21 | void returnBook(void);
22 |
23 | void load();
24 | void save();
25 |
26 | public:
27 | static map s_bookMap;
28 | static map s_customerMap;
29 |
30 | static map bookLoanMap;
31 | static map> bookReservationSetMap;
32 |
33 | static map> customerLoanSetMap;
34 | static map> customerReservationSetMap;
35 | };
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/LibraryBasic.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Chapter03/LibraryBasic/Main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include