DynamicArray + vector 使用难题

tree2000 2008-01-11 11:25:33
如下代码:
struct S_Block
{
String A1;
String A2;
S_Block( String A01,String A02 ) : A01(A1),A02(A2)
{
};
S_Block():A1(""),A2("")
{
}

bool operator < ( S_Block( const &B1) )
{
return A1 < B1.A1;
}
};

DynamicArray<S_Block> S001;

void __fastcall Function( void )
{
int DataCount = S1.Length;
vector<S_Block> V1(S001[0],S001[DataCount-1] );
stable_sort( V1.Begin(),V1.End() );
}

编译出错:
好象是DynamicArray不能与向量组合,那有啥办法做到这一点呢?
...全文
73 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tree2000 2008-01-14
  • 打赏
  • 举报
回复
嘿。说得有理,答得正确。当时,IDE没在身边哈。初次使用STL,还不怎么熟哈。
谢谢。
ydlchina 2008-01-11
  • 打赏
  • 举报
回复
高难度问题,顶顶
Waiting4you 2008-01-11
  • 打赏
  • 举报
回复
程序本身错误百出,问问题不诚心。调试一下还得改一大堆代码错误。

struct   S_Block
{
String A1;
String A2;
S_Block(String A01,String A02)
:A1(A01),A2(A02)
{
}

S_Block():A1(""),A2("")
{
}

bool operator< ( const S_Block &B1) const
{
return A1 < B1.A1;
}
};

DynamicArray <S_Block> S001;

void __fastcall Function( void )
{
int DataCount = S001.Length;
vector <S_Block> V1(&S001[0],&S001[0]+DataCount);
stable_sort(V1.begin(),V1.end());

for(int i=0; i<DataCount; i++) S001[i] = V1[i];
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
S001.Length = 10;
for(int i=0; i<10; i++) S001[i] = S_Block(IntToStr(10-i),IntToStr(10-i)); // 弄10个数据进去

for(int i=0; i<10; i++) Memo1->Lines->Add(S001[i].A1 + ":" + S001[i].A2); // 显示结果
::Function(); //操作
for(int i=0; i<10; i++) Memo1->Lines->Add(S001[i].A1 + ":" + S001[i].A2); // 显示结果
}
//---------------------------------------------------------------------------

13,824

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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