一个C++的问题!请高手帮个忙!

来源:百度知道 编辑:UC知道 时间:2024/07/01 03:51:16
给字符串类定义下列重载运算符函数:
A赋值运算符=,
B连接运算符+,
C关系运算符>
用到友元函数!
我要全部函数!不是简单的代码!
我只有这些分了!谢谢!!!
我们学的就是C++,当然是的了 肯定好
写一个能够直接运行出来的完整 程序

const CString& CString::operator=(const CString& stringSrc)
{
if (m_pchData != stringSrc.m_pchData)
{
if ((GetData()->nRefs < 0 && GetData() != _afxDataNil) ||
stringSrc.GetData()->nRefs < 0)
{
// actual copy necessary since one of the strings is locked
AssignCopy(stringSrc.GetData()->nDataLength, stringSrc.m_pchData);
}
else
{
// can just copy references around
Release();
ASSERT(stringSrc.GetData() != _afxDataNil);
m_pchData = stringSrc.m_pchData;
InterlockedIncrement(&GetData()->nRefs);
}
}
return *this;
}

void CString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
int nSrc2Len, LPCTSTR lpszSrc2Data)
{
// -- master concatenation routine
// Concatenate two sources
// -- assume that 'this' is a new CString object

int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen