-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
193 lines (173 loc) · 4.98 KB
/
main.cpp
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include "unit_2_sum_example/headers/ShapesContainer.h"
#include "examples_vuls/BaseUser.h"
#include "examples_vuls/Number.h"
#include "unit_5_examples/headers/socketDemo.h"
#include "unit_5_examples/headers/boostDemo.h"
#include "unit_5_examples/headers/SocketBoostClientDemo.h"
#include "unit_5_examples/headers/SocketBoostServerDemo.h"
#include "boost_asio_demos/headers/asio_example.h"
#include <cstring>
using namespace std;
int main(int argc, char* argv[]) {
// testBaseUserClass();
// testPrivateHackValue();
// testDynamicCast();
// testOperatorPolymorphism();
// testVirtualDestructors();
// testVariantReturn();
// Wind flute;
// Percussion drum;
// Stringed violin;
// Brass flugelhorn;
// Woodwind recorder;
// tune(flute);
// tune(drum);
// tune(violin);
// tune(flugelhorn);
// tune(recorder);
// f(flugelhorn);
// testAddingVirtualsClass();
// Stack s1; // Stack memory
//
// SecureStack s3;
// s3.print();
//
// Stack* sptr;
// sptr = &s3;
//
// // Virtual function, binding at runtime
// sptr->print();
//
// // Non-virtual function, binding at compile time
// sptr->show();
//
// int index = 0;
// while (index < 15) {
// s1.Push(index);
// index++;
// }
//
//
// Stack* s2 = new Stack(); // Heap memory
// s2->Push(14);
// delete s2;
//
// Point p1(5, 7);
// Point p2(1, 2);
// Point p3;
// p3 = p1 + p2;
//
// showStreamExamples();
// showConcatExample();
// helloStrings();
//
// std::string filename = "../examples_ch2/Vector.cpp";
// std::string wordToCount = "i";
// countWordOccurrences(filename, wordToCount);
//
// int totalWords = countWhiteSeperatedWords(filename);
// if (totalWords != -1) {
// std::cout << "Total number of words in file: " << totalWords << std::endl;
// }
// fillVector();
// floatVector(0.0, 100.0, 20);
// removeHat('C');
// specifiers();
// Pointers and References
// demonstratePassingMethods();
// cout << "globe: " << globe << endl;
// specifiers();
// cout << "globe: " << globe << endl;
//
// bitwiseOperatorsDemo();
// bitRotationLeft(150);
// bitRotationRight(150);
// bitRotationLeft(151);
// bitRotationRight(151);
// constCastDemo();
// reinterpretCastDemo();
// explicitOperatorsDemo();
// simpleStruct();
//
// cout << "argc = " << argc << endl;
// for (int i = 0; i < argc; i++)
// cout << "argv[" << i << "] = "
// << argv[i] << endl;
//
// double d = atof("3.14159");
// unsigned char* cp =
// reinterpret_cast<unsigned char*>(&d);
// for (int i = sizeof(double); i > 0; i -= 2) {
// printBinary(cp[i - 1]);
// printBinary(cp[i]);
// }
//
// int i[10];
// double q[10];
// int* ip = i;
// double* dp = q;
//
// ip[0] = 3;
// ip[1] = 5;
// dp[0] = 3.14;
// dp[1] = 6.28;
//
// std::cout << "ip = " << reinterpret_cast<uintptr_t>(ip) << std::endl;
// std::cout << "*ip = " << *ip << std::endl;
// ip++;
// std::cout << "ip = " << reinterpret_cast<uintptr_t>(ip) << std::endl;
// std::cout << "*ip = " << *ip << std::endl;
//
// std::cout << "dp = " << reinterpret_cast<uintptr_t>(dp) << std::endl;
// std::cout << "*dp = " << *dp << std::endl;
// dp++;
// std::cout << "dp = " << reinterpret_cast<uintptr_t>(dp) << std::endl;
// std::cout << "*dp = " << *dp << std::endl;
//
// pointerArithmeticDemo();
// pointerToFunction();
// functionTable();
// functionTable2();
// testCLib();
// testStructSizes();
// testNestedFriend();
// Ex3 ex3{};
// cout << showValue(&ex3) << endl;
// changeValue(&ex3, 5);
// cout << showValue(&ex3) << endl;
// testTreeClass();
// int i_test = 4;
// int* i_pointer = &i_test;
// cout << &i_test << endl;
// cout << i_pointer << endl;
// *i_pointer = 10;
// cout << i_test << endl;
// cout << *i_pointer << endl;
// testStash3();
// testMultiArg();
// testStack3();
// showFreeStandingReferenceDemo();
// referenceToPointerDemo();
// testHowMany2();
// testComposite();
// testDataClass();
// testWidget1();
// testTreeClass();
// testNameHiding();
// testSynthesizeFunctions();
// testFNameClass();
// testByte2();
// testCCUpCastingDemo();
// createClientSocketDemo();
// testClientBoostAsio();
// socketBoostClientDemoRun(argc, argv);
// Server setup with hardcoded port
// const char *serverArgv[] = {"cpp_playground", "1234"}; // Server port 1234
// int serverArgc = sizeof(serverArgv) / sizeof(char *);
//// socketBoostServerDemoRun(serverArgc, const_cast<char**>(serverArgv));
// Client setup with hardcoded server IP and port
// const char *clientArgv[] = {"cpp_playground", "127.0.0.1", "65431"}; // Server IP 127.0.0.1, Server port 1234
// int clientArgc = sizeof(clientArgv) / sizeof(char *);
// socketBoostClientDemoRun(clientArgc, const_cast<char **>(clientArgv));
// // runAsioExample1();
}