📄 stringnode.cpp
字号:
// StringNode.cpp: implementation of the CStringNode class.
//
//////////////////////////////////////////////////////////////////////
#include "StringNode.h"
#include "string.h"
#include "iostream.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CStringNode::CStringNode(char* strvalue)
{
m_strValue = new char[strlen(strvalue)+1];
strcpy(m_strValue,strvalue);
}
CStringNode::CStringNode(const CStringNode& node)
{
m_strValue = new char[strlen(node.m_strValue)+1];
strcpy(m_strValue,node.m_strValue);
}
CStringNode::~CStringNode()
{
delete[] m_strValue;
m_strValue = 0;
}
void* CStringNode::Visit()
{
cout << m_strValue << endl;
return m_strValue;
}
CStringNode& CStringNode::operator= (const CStringNode& node)
{
delete[] m_strValue;
m_strValue = new char[strlen(node.m_strValue)+1];
strcpy(m_strValue,node.m_strValue);
return *this;
}
bool CStringNode::operator == (const CNodeBase* base)
{
CNodeBase* pBase = const_cast<CNodeBase*>(base);
CStringNode* pNode = dynamic_cast<CStringNode*>(pBase);
if( pNode==0 )
return false;
if(strcmp(pNode->m_strValue,this->m_strValue)==0)
return true;
else
return false;
/* if( strcmp(m_strValue,node.m_strValue)==0 )
return true;
else
return false;*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -