-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
132 lines (112 loc) · 3.45 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
// #include "Basic-CPP/basic.h"
#include <basic.h> // we can use this because we use `target_include_directories` in root CMakeLists.txt
#include <iostream>
#include <modern.h>
#include <nodeflux.h>
#include <oop.h>
#include <pointer.h>
int main() {
/* BASIC */
std::cout << "[BASIC]" << std::endl;
create_response();
create_base_data(10);
// File
read_file_to_string();
// append_to_file();
// lvalue and rvalue
std::string hello = "Hello ", mom = "mom!", world = "world!";
print(hello); // "hello" is a lvalue
print("world!"); // "world!" is an rvalue
print(std::move(mom)); // "mom!" is an rvalue
// print(std::move(mom)); // WARN = don't ever to try access variable "mom"
// again!
std::string firstname = "Mr", lastname = "X";
print_name("Mr. X");
print_name(firstname + lastname); // we can do this because we use const in
// the parameter of the function
// print_full_name(firstname); // ERROR: because this function only accept
// rvalue reference
print_full_name(firstname + lastname); // we input rvalue as the argument
std::cout << std::endl;
// enum
std::cout << "enum token: \n";
print_token_type();
std::cout << std::endl;
// union
std::cout << "union: \n";
dataType();
std::cout << std::endl;
std::cout << "+-----------------------------------+" << std::endl
<< std::endl;
/* MODERN */
std::cout << "[MODERN]" << std::endl;
// type
some_cool_things();
Bird bird{
bird.x_coordinate = 10,
bird.y_coordinate = 9,
bird.speed = 8,
};
Bird::fly(bird);
print_bird(bird);
std::cout << std::endl;
// function pointer
auto call_func = hello_func_pointer;
// typedef void(*HelloFuncPointer)(int); // this is same with previous one
call_func(313);
std::vector<int> values = {1, 3, 5, 2, 8};
ForEach(values, PrintValue);
lambdas(values);
std::cout << std::endl;
// template
PrintData<int>(300);
PrintData<float>(30.3);
std::cout << std::endl;
// const and mutable
ConstKeyword();
std::cout << std::endl;
MutableKeyword();
std::cout << std::endl;
std::cout << "+-----------------------------------+" << std::endl
<< std::endl;
/* OOP */
std::cout << "[OOP]" << std::endl;
Enemy enemy{3, 5, 1.2};
std::cout << enemy << std::endl;
SmallEnemy sm(3, 9.9); // SmallEnemy only need to specify 2 arguments instead
// of 3 like Enemy
std::cout << "small-enemy: " << sm << std::endl;
std::cout << std::endl;
oopPlayground();
std::cout << std::endl;
std::cout << "+-----------------------------------+" << std::endl
<< std::endl;
/* POINTER */
// std::cout << "[POINTER]" << std::endl;
// // raw pointer
// std::cout << "raw pointer: \n";
// basic_pointer();
// play_pokemon();
//
// // smart pointer
// std::cout << "smart pointer: \n";
// smartPointer();
// std::cout << std::endl;
// std::cout << "+-----------------------------------+" << std::endl
// << std::endl;
/* Nodeflux */
std::cout << "[NODEFLUX]" << std::endl;
msgPackIntroduction();
std::cout << std::endl;
// libasyikIntroduction();
// std::cout << std::endl;
zeroMQIntroduction();
std::cout << std::endl;
zeroMQMultipartMessage();
std::cout << std::endl;
// zeroMQReqRep();
// std::cout << std::endl;
std::cout << "+-----------------------------------+" << std::endl
<< std::endl;
// return 0;
}