Calculator  Step 3
Functions
variables.cpp File Reference
#include <map>
#include "variables.hpp"

Go to the source code of this file.

Functions

double get_variable (std::string const &name)
 
void set_variable (std::string name, double value)
 

Function Documentation

double get_variable ( std::string const &  name)

Get the value of a variable.

Parameters
nameThe variable name
Returns
The value of variable name or 0.0 if the variable is undefined.

Definition at line 18 of file variables.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and node_identifier::evaluate_node().

19 {
20  return variables[name];
21 }
void set_variable ( std::string  name,
double  value 
)

Set the value of a variable.

Parameters
nameThe variable name
valueThe value. if the variable is already defined, changes its value.

Definition at line 23 of file variables.cpp.

Referenced by node_assign::evaluate_node().

24 {
25  variables[std::move(name)] = value;
26 }