我的函数 void show(const SOP & sop)
应该通过调用不同的显示函数来输出一组有序对,该函数输出下面定义的有序对,告诉我存在非法间接的错误,代码C2100,代码C2100,但是我不确定为什么是这种情况。
SOP代表一组有序对。OP代表有序对。所有的帮助都得到赞赏。
#include <algorithm> // pair
#include <iostream>
#include <set> // set
#include <cassert> // assert
#include <iterator>
using namespace std;
typedef pair<unsigned, unsigned> OP;
typedef set<OP> SOP;
void show(const OP & op);
void show(const SOP & sop);
int main() {
show(OP(7,3));
SOP x((1, 1), (3, 2), (5,4));
show(x);
}
void show(const OP & op) {
cout << "(" << op.first << "," << op.second << ")" << endl;
}
void show(const SOP & sop) {
for (const OP & n: sop) {
show(n);
}
}
所以此代码
SOP x((1, 1), (3, 2), (5, 4));
应该使用牙套而不是parens
SOP x{{1, 1}, {3, 2}, {5, 4}};
随着这种变化,一切似乎都按顺序进行。