Calculator  Step 2
variables.cpp
Go to the documentation of this file.
1 #include <map>
2 
3 #include "variables.hpp"
4 
5 namespace {
6  std::map<std::string, double> variables;
7 
8  class initializer {
9  public:
10  initializer() {
11  variables["pi"] = 3.141592653589792;
12  variables["e"] = 2.718281828459;
13  }
14  };
15  initializer init;
16 }
17 
18 double get_variable(std::string const& name)
19 {
20  return variables[name];
21 }
22 
23 void set_variable(std::string name, double value)
24 {
25  variables[std::move(name)] = value;
26 }
void set_variable(std::string name, double value)
Definition: variables.cpp:23
double get_variable(std::string const &name)
Definition: variables.cpp:18