小编Joh*_*ith的帖子

C++ - 从Set打印对象

如果我有一个C++集和迭代器:

set<Person> personList;
set<Person>::const_iterator location;
Run Code Online (Sandbox Code Playgroud)

如何打印出套装内容?它们都是person对象,我重载了operator << for Person.

错误在基本for循环中的行:

cout << location
Run Code Online (Sandbox Code Playgroud)

Netbeans给出:

proj.cpp:78:错误:'std :: cout << location'中'operator <<'不匹配

看起来它想要迭代器的运算符<<的重载.

基本上,我正在使用以数组格式存储的对象,但现在是一组.cout << array[i]集合的等价物是什么?

c++

6
推荐指数
3
解决办法
4万
查看次数

标签 统计

c++ ×1