0

我有使用 BorlandC++Tlist和其他 Borland 特定类编写的遗留代码。我完全是 STL 的菜鸟。

我不知道如何重新声明一个看起来像这样的构造函数:

MyData (TStringList *fileList)

下面的声明给出了缺少“)”的错误!(在 BorlandC++/embarcadero 中编译)

MyData (std:list<string> *fileList)

上面有什么问题?应该如何声明std:list

(我知道很多代码必须更改,因为TStringList没有相同的方法std:list。)

4

1 回答 1

2

命名空间使用范围解析运算符::,而不是单个冒号:

list和都stringstd命名空间中,因此可以使用::

这有效:MyData(std::list<std::string> *fileList)


来自 Thomas Matthews 的评论:通过引用传递优于通过指针传递:MyData(std::list<std::string> &fileList)

于 2019-02-16T17:33:11.447 回答