#pragma once
#include "Phone.h"
class ArrayList :
public Phone
{
public:
ArrayList(const int& max=4);
~ArrayList(void);
ArrayList& Append(const string& x);
};
#include "stdafx.h"
#include "ArrayList.h"
#include "Phone.h"
ArrayList::ArrayList(const int& max):Phone(max)
{
}
ArrayList::~ArrayList(void)
{
}
ArrayList& ArrayList::Append(const string& x)
{
if (Cur_Length==Max_Length)
{
Max_Length *=2;
string *p=new string [Max_Length];
memcpy(&p,&_Message,sizeof(_Message)*Cur_Length);
delete [] _Message;
_Message=p;
}
_Message[Cur_Length++]=x;
return *this;
}
#include "stdafx.h"
#include "Phone.h"
#include "ArrayList.h"
int _tmain(int argc, _TCHAR* argv[])
{
ArrayList message(2);
message.Append("HI").Append("I").Append("AM").Append("L").Append("NICE").Append("TO").Append("MEET").Append("U");
return 0;
}
总是运行出错,谁能拯救我!!!!!