在 Borland C++ 中构建 STL 应用程序建造者5.0

发布于 2024-10-08 14:46:22 字数 1220 浏览 0 评论 0原文

我是 Borland C++ builder 5.0 的新手。我使用过小型 STL 应用程序,该应用程序在一台机器(Windows 2003 Server SP2)中编译成功,但在另一台机器(Windows XP 机器 SP3)中编译失败。我已经放置了代码片段和错误消息

Error E2285 Could not find a match for 'distance<>(const AnsiString *,const AnsiString *,i
nt)

我已打开 Borland C++ Form 并在 Form Create 中添加了以下代码

#include <vcl.h>
#pragma hdrstop
#include <vector>

using namespace std;
using std::distance;

static const AnsiString Text_FieldsInTypen[]=
{
  "code_segment_national_2"
};

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   vector<AnsiString> aVec;
   aVec.push_back("Test");

   const AnsiString*  Iter;
   int Index = 0;
   distance(Text_FieldsInTypen, Iter, Index);

}
//---------------------------------------------------------------------------

I am new to Borland C++ builder 5.0.I have used small STL application which is compiled successfully in one machine(Window 2003 Server SP2), but not in another machine (Windows XP machine SP3). I have placed an code snippet and error message

Error E2285 Could not find a match for 'distance<>(const AnsiString *,const AnsiString *,i
nt)

I have opened Borland C++ Form and added the below code in Form Create

#include <vcl.h>
#pragma hdrstop
#include <vector>

using namespace std;
using std::distance;

static const AnsiString Text_FieldsInTypen[]=
{
  "code_segment_national_2"
};

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   vector<AnsiString> aVec;
   aVec.push_back("Test");

   const AnsiString*  Iter;
   int Index = 0;
   distance(Text_FieldsInTypen, Iter, Index);

}
//---------------------------------------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2024-10-15 14:46:22

距离算法需要两个迭代器:

template<class InputIterator>
   typename iterator_traits<InputIterator>::difference_type
      distance(
         InputIterator _First, 
         InputIterator _Last
            );

而不是三个不相关的参数。

Iter 也可以在代码中以未初始化的方式使用。

The distance algorithm takes two iterators:

template<class InputIterator>
   typename iterator_traits<InputIterator>::difference_type
      distance(
         InputIterator _First, 
         InputIterator _Last
            );

Not three unrelated arguments.

Iter is also used uninitialized in your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文