【发布时间】:2020-08-09 16:40:46
【问题描述】:
在这里我定义了 push_back 并在我的代码中使用它,但在执行以下任务后不知道。
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int> v[1001];
这是下面这个错误
prog.cpp:4:12: error: request for member ‘push_back’ in ‘v’, which is of non-class type ‘std::vector<int> [1001]’
#define pb push_back
【问题讨论】:
-
作为提示,使用 IDE/编辑器可以帮助您自动完成 push_back 等内容,而不是使用定义。维护这样的代码将成为一场噩梦。
-
等到
std::pb被添加到 C++ 27 的库中。 -
pb-- 和here使用的疯狂宏是一样的 -
@PaulMcKenzie -- 哦,那个链接很好......
标签: c++ algorithm c++11 data-structures c++14