如何访问指向结构中的向量的指针的值?我有以下代码:访问指向结构中的向量的指针
#include <iostream>
#include <vector>
using namespace std;
struct item {
int value;
vector<bool> pb;
vector<bool> *path = &pb;
};
int main(int argc, char* argv[]) {
vector<item> dp(10);
for (int n = 0; n < 10; n++)
dp[n].pb = vector<bool>(10);
if (dp[1].path[2] == true)
cout << "true";
else cout << "false";
}
这将导致以下编译错误:
Error C2678 binary '==': no operator found which takes a left-hand operand of type 'std::vector<bool,std::allocator<_Ty>>' (or there is no acceptable conversion)
我如何可以访问存储在DP值[1]。路径[2]?
与从指针访问不在结构中的向量的值相同的方式。 – juanchopanza