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