Calculator  Step 3
Public Member Functions | Private Member Functions | List of all members
node_negate Class Reference

#include <node_impl.hpp>

Inheritance diagram for node_negate:
node_unary node_impl

Public Member Functions

 node_negate (node operand)
 
- Public Member Functions inherited from node_unary
 node_unary (node operand)
 
node operand () 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
 

Private Member Functions

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

Additional Inherited Members

- Protected Member Functions inherited from node_unary
double evaluate_operand () const
 

Detailed Description

Unary negation.

Definition at line 129 of file node_impl.hpp.

Constructor & Destructor Documentation

node_negate::node_negate ( node  operand)

Definition at line 207 of file node_impl.cpp.

208 : node_unary{operand}
209 {}

Member Function Documentation

double node_negate::evaluate_node ( ) const
overrideprivatevirtual

Implements node_unary.

Definition at line 218 of file node_impl.cpp.

References node_unary::evaluate_operand().

220 {
221  return -evaluate_operand();
222 }
double evaluate_operand() const
Definition: node_impl.cpp:172
void node_negate::print_node ( std::ostream &  stream,
int  indent 
) const
overrideprivatevirtual

Implements node_unary.

Definition at line 211 of file node_impl.cpp.

References node_unary::operand(), and node::print().

213 {
214  stream << std::setw(indent) << "" << "-\n";
215  operand().print(stream, indent + 2);
216 }
void print(std::ostream &stream, int indent=0) const
Definition: node.cpp:44
node operand() const
Definition: node_impl.cpp:166

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