怎么使string顺序表改成线性集合?

杰克船长1015 2014-04-23 04:53:52
#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;
}

总是运行出错,谁能拯救我!!!!!
...全文
53 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
杰克船长1015 2014-04-23
  • 打赏
  • 举报
回复
来人啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧