67 111 C:\Users\Caterina\Desktop\未命名1.cpp [Error] could not convert '{81, 98, 188, 37, 112, 18, 18, 60, 67, 146, 166}' from '<brace-enclosed initializer list>' to 'std::vector<int>'如何解决这个错误
时间: 2024-02-26 10:57:23 浏览: 100
这个错误的原因是你试图将一个大括号括起来的初始化列表作为参数传递给一个 `std::vector<int>` 对象。你可以尝试将初始化列表中的元素一个一个地添加到 `std::vector<int>` 对象中,或者使用 `std::vector<int>` 的构造函数来将初始化列表转换为 `std::vector<int>` 对象,如下所示:
```c++
std::vector<int> vec = {81, 98, 188, 37, 112, 18, 18, 60, 67, 146, 166};
```
如果你使用的是旧的编译器或者标准库,可能不支持初始化列表,那么你可以使用以下代码:
```c++
int arr[] = {81, 98, 188, 37, 112, 18, 18, 60, 67, 146, 166};
std::vector<int> vec(arr, arr + sizeof(arr) / sizeof(int));
```
这将使用数组来初始化 `std::vector<int>` 对象。
相关问题
s41598-021-96434-0 .pdf
1. The study focuses on the accuracy of decision-making in brain-computer interfaces (BCIs) using neural features and response times (RTs) as important correlates.
2. Collaborative BCIs can enhance perceptual group decision-making.
3. The authors of the study are Saugat Bhattacharyya, Davide Valeriani, Caterina Cinel, Luca Citi, and Riccardo Poli from Ulster University and Essex University.
阅读全文