// File: DoubleNode.cpp // // DoubleNode Implementation #include #include #include "DoubleNode.h" using namespace std ; // Constructor. Note that data defaults to 0. // DoubleNode::DoubleNode (double data /* = 0.0 */ ) : m_data(data) { // do nothing else } void DoubleNode::print(ostream& os /*=cout*/) const { os << m_data ; } DoubleNode *DoubleNode::clone() const { #ifndef NDEBUG cerr << " DoubleNode clone\n" ; #endif return new DoubleNode(m_data) ; } bool DoubleNode::operator==(const HNode& rhs_ref) const { // comparing apples to oranges?? if (typeid(rhs_ref) != typeid(DoubleNode)) return false ; // This could throw an exception, but we already checked typeids const DoubleNode& rhs = dynamic_cast(rhs_ref) ; return m_data == rhs.m_data ; } double DoubleNode::get() const { return m_data ; } void DoubleNode::set(double data) { m_data = data ; }