-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleCommand.cc
More file actions
34 lines (30 loc) · 806 Bytes
/
simpleCommand.cc
File metadata and controls
34 lines (30 loc) · 806 Bytes
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
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "simpleCommand.hh"
SimpleCommand::SimpleCommand() {
// vector functionalities: 1. vec[i]; 2. push_back.
//3. vectors work as
_arguments = std::vector<std::string *>();
}
SimpleCommand::~SimpleCommand() {
// iterate over all the arguments and delete them
for (auto & arg : _arguments) {
delete arg;
}
}
void SimpleCommand::insertArgument( std::string * argument ) {
// simply add the argument to the vector at end
_arguments.push_back(argument);
}
// Print out the simple command
void SimpleCommand::print() {
for (auto & arg : _arguments) {
std::cout << "\"" << *arg << "\" \t";
}
// effectively the same as printf("\n\n");
std::cout << std::endl;
}