Calculator  Step 5
Public Member Functions | Private Member Functions | List of all members
node_subtract Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_subtract:
node_binary node_impl

Public Member Functions

 node_subtract (node left, node right)
 
 node_subtract (std::istream &stream)
 
- Public Member Functions inherited from node_binary
 node_binary (node left, node right)
 
node left () const
 
node right () const
 
- Public Member Functions inherited from node_impl
 node_impl ()
 
virtual ~node_impl ()
 
void print (std::ostream &stream, int indent) const
 
double evaluate () const
 
std::string to_string () const
 
identifier_list const & get_parameters () const
 
void save (std::ostream &stream) const
 

Private Member Functions

virtual void print_node (std::ostream &stream, int indent) const override
 
virtual double evaluate_node () const override
 
virtual void save_node (std::ostream &stream) const override
 

Additional Inherited Members

- Static Public Member Functions inherited from node_impl
static std::shared_ptr< node_implread_node (std::istream &stream)
 
- Protected Member Functions inherited from node_binary
 node_binary (std::istream &stream)
 
double evaluate_left () const
 
double evaluate_right () const
 

Detailed Description

Subtraction.

Definition at line 188 of file node_impl.hpp.

Constructor & Destructor Documentation

node_subtract::node_subtract ( node  left,
node  right 
)

Definition at line 466 of file node_impl.cpp.

References node_binary::left().

467 : node_binary{left, right}
468 {}
node left() const
Definition: node_impl.cpp:380
node_subtract::node_subtract ( std::istream &  stream)

Definition at line 470 of file node_impl.cpp.

471 : node_binary{stream}
472 {}

Member Function Documentation

double node_subtract::evaluate_node ( ) const
overrideprivatevirtual

Implements node_binary.

Definition at line 482 of file node_impl.cpp.

References node_binary::evaluate_left(), and node_binary::evaluate_right().

484 {
485  return evaluate_left() - evaluate_right();
486 }
double evaluate_right() const
Definition: node_impl.cpp:398
double evaluate_left() const
Definition: node_impl.cpp:392
void node_subtract::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_binary.

Definition at line 474 of file node_impl.cpp.

References node_binary::left(), node::print(), and node_binary::right().

476 {
477  stream << std::setw(indent) << "" << "-\n";
478  left().print(stream, indent + 2);
479  right().print(stream, indent + 2);
480 }
node right() const
Definition: node_impl.cpp:386
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:54
node left() const
Definition: node_impl.cpp:380
void node_subtract::save_node ( std::ostream &  stream) const
overrideprivatevirtual

Implements node_binary.

Definition at line 488 of file node_impl.cpp.

References node_binary::left(), node_binary::right(), and node::save().

490 {
491  stream << "subtract ";
492  left().save(stream);
493  right().save(stream);
494 }
node right() const
Definition: node_impl.cpp:386
void save(std::ostream &stream) const
Definition: node.cpp:78
node left() const
Definition: node_impl.cpp:380

The documentation for this class was generated from the following files: