forked from faranakR/full-cpp-tutorial-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter_31_advanced_topics.cpp
More file actions
95 lines (74 loc) · 2.49 KB
/
chapter_31_advanced_topics.cpp
File metadata and controls
95 lines (74 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*=============================================================================
* CHAPTER 31: ADVANCED TOPICS
* =============================================================================
*
* C++ Development Course - Consolidated Examples
* Original Author: Faranak Rajabi
*
* This file contains 4 code example(s) from Chapter 31.
*
* USAGE:
* - Review each example section
* - Uncomment the code you want to test
* - Compile: g++ -std=c++17 -Wall thisfile.cpp -o program
* - Run: ./program
*
* NOTE:
* Some examples are code snippets designed to illustrate specific
* concepts and may need additional context to compile.
*
=============================================================================*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
// ============================================================================
// EXAMPLE 1: When modification is needed
// ============================================================================
/*
}
// When modification is needed
void sortVector ( std :: vector < int >& data ) {
// Can modify the original vector
std :: sort ( data . begin () , data . end () ) ;
31 }
*/
// ============================================================================
// EXAMPLE 2: Function: main
// ============================================================================
int main () {
int x {5};
modifyValue ( x ) ;
std :: cout << x << ’\ n ’;
// ============================================================================
// EXAMPLE 3: Prevent inheritance entirely
// ============================================================================
/*
};
// Prevent inheritance entirely
class FinalClass final {
// ...
31 };
// class Derived : public FinalClass {};
*/
// ============================================================================
// EXAMPLE 4: Class: N
// ============================================================================
/*
class N e t w o r k E x c e p t i o n : public std :: exception {
public :
enum ErrorCode {
C O N N E C T I O N _ F A I L E D = 1001 ,
TIMEOUT = 1002 ,
I N V A L I D _ R E S P O N S E = 1003
};
*/
// ============================================================================
// MAIN FUNCTION
// ============================================================================
// Uncomment the examples above and add your test code here
int main() {
std::cout << "Chapter 31: Advanced Topics" << std::endl;
// Your test code here
return 0;
}