-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (60 loc) · 1.28 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (60 loc) · 1.28 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
#include <iostream>
#include <map>
#include <string>
#include <numeric>
#include <vector>
#include <memory>
#include "argalparser.hpp"
#include "integer_fun.hpp"
#include "vector_fun.hpp"
#include "class_fun.hpp"
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::partial_sum;
using std::shared_ptr;
using std::unique_ptr;
using std::make_shared;
using std::make_unique;
static ivector nums_to_sum;
bool
integer_fun_callback(const char*)
{
integer_fun();
return false;
}
bool
vector_fun_callback(const char*)
{
vector_fun();
return false;
}
bool
register_number_callback(const char* param)
{
int num = atoi(param);
if (0 != num)
{
nums_to_sum.push_back(num);
}
return true;
}
int
main(int argc, char const* argv[])
{
assign_callback_to_arg("-ex1", example_callback);
assign_callback_to_arg("-ex2", example_callback_with_argument);
assign_callback_to_arg_LOG("-i", integer_fun_callback);
assign_callback_to_arg_LOG("-v", vector_fun_callback);
assign_callback_to_arg_LOG("-s", register_number_callback);
process_args(argc, argv);
print_ints("nums_to_sum = ", nums_to_sum);
if (nums_to_sum.size() > 0)
{
add_ints_in_place(&nums_to_sum);
cout << "The sum = " << nums_to_sum.back() << endl;
}
class_fun();
return 0;
}