指定vector <bool>

时间:2016-12-22 12:36:19

标签: c++ vector

我正在尝试按如下方式分配矢量bool:

var nfi = (NumberFormatInfo)CultureInfo.CurrentCulture.NumberFormat.Clone();
nfi.NumberGroupSeparator = " ";

string value = amount.ToString("n2", nfi);

它编译好,但得到以下运行时错误:

#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);
}

An invalid parameter was passed to a function that considers invalid parameters fatal. dp的值为

enter image description here

如何将矢量bool分配给现有变量?

0 个答案:

没有答案