Calculator  Step 3
node.hpp
Go to the documentation of this file.
1 #ifndef NODE_HPP_
2 #define NODE_HPP_
3 
4 #include <iosfwd>
5 #include <string>
6 #include <memory>
7 
9 class node_impl;
10 
16 class node {
17 public:
19  node();
23  node(double number);
27  node(std::string identifier);
32  node(node identifier, node number);
37  node(char op, node operand);
43  node(node left, char op, node right);
44 
45  ~node() = default;
46  node(node const&) = default;
47  node(node&&) = default;
48  node& operator=(node const&) = default;
49  node& operator=(node&&) = default;
50 
57  void print(std::ostream& stream, int indent = 0) const;
61  double evaluate() const;
66  std::string to_string() const;
67 
68 private:
70  static std::shared_ptr<node_impl> make_binary_operator(node, char, node);
71 
72  std::shared_ptr<node_impl> pimpl_;
73 };
74 
75 #endif
Definition: node.hpp:16
std::shared_ptr< node_impl > pimpl_
Definition: node.hpp:72
static std::shared_ptr< node_impl > make_binary_operator(node, char, node)
Factory function to make the binary operator nodes.
Definition: node.cpp:6
node & operator=(node const &)=default
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:44
std::string to_string() const
Definition: node.cpp:56
double evaluate() const
Definition: node.cpp:50
node()
Definition: node.cpp:20
~node()=default