一个模板类问题
我写了一个链表模板类, 编写了测试代码, 发生错误, 哪一位高手替我检查一下错在哪儿.
下面的这些是测试代码
#include "mztempl.h"
using namespace mzdatastruct;
class my1
{
public:
CChain<int> m_i;
int a;
my1()
{
a = 100;
m_i.AddTail(&a);
}
my1(const my1& p)
{
*this = p;
}
void operator = (const my1& p)
{
a = p.a;
m_i.RemoveAll();
ELEMENT_POSITION pos = m_i.GetHeadPosition();
while (pos)
{
int mmm = p.m_i.GetAt(pos);
m_i.AddTail(&mmm);
p.m_i.GetNext(pos);
}
}
};
class my_root
{
public:
int b;
CChain<my1> my;
my_root()
{
my1 m;
my.AddTail(&m);
}
my_root(const my_root& p)
{
*this = p;
}
void operator = (const my_root& p)
{
b = p.b;
my.RemoveAll();
ELEMENT_POSITION pos = p.my.GetHeadPosition();
while (pos)
{
my1 temp = p.my.GetAt(pos);
my.AddTail(&temp);
p.my.GetNext(pos);
}
}
};