Я пытаюсь создать вектор, содержащий другие векторы с плавающей точкой и другим вектором целых чисел. Ожидаемый результат:
{{5.4 {1, 5, 4, 6, 9},
4.8, {3, 6, 7, 8, 4},
7.3 , {9, 12, 1, 0, 4}}
Это одна из моих попыток:
#include <iostream>
#include <vector>
using namespace std;
void _cost(){
vector<float, vector<int>> result;
cout<<"This work";
}
int main(){
_cost();
return 0;
}
Во всех моих попытках я получаю следующую ошибку:
In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0,
from /usr/include/c++/7/bits/basic_string.h:40,
from /usr/include/c++/7/string:52,
from /usr/include/c++/7/bits/locale_classes.h:40,
from /usr/include/c++/7/bits/ios_base.h:41,
from /usr/include/c++/7/ios:42,
from /usr/include/c++/7/ostream:38,
from /usr/include/c++/7/iostream:39,
from prueba_dela_prueba.cpp:1:
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of ‘static void std::allocator_traits<_Alloc>::deallocate(_Alloc&, std::allocator_traits<_Alloc>::pointer, std::allocator_traits<_Alloc>::size_type) [with _Alloc = std::vector<float, std::allocator<int> >; std::allocator_traits<_Alloc>::pointer = float*; std::allocator_traits<_Alloc>::size_type = long unsigned int]’:
/usr/include/c++/7/bits/stl_vector.h:180:19: required from ‘void std::_Vector_base<_Tp, _Alloc>::_M_deallocate(std::_Vector_base<_Tp, _Alloc>::pointer, std::size_t) [with _Tp = float; _Alloc = std::vector<int>; std::_Vector_base<_Tp, _Alloc>::pointer = float*; std::size_t = long unsigned int]’
/usr/include/c++/7/bits/stl_vector.h:162:22: required from ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = float; _Alloc = std::vector<int>]’
/usr/include/c++/7/bits/stl_vector.h:263:15: required from ‘std::vector<_Tp, _Alloc>::vector() [with _Tp = float; _Alloc = std::vector<int>]’
prueba_dela_prueba.cpp:9:32: required from here
/usr/include/c++/7/bits/alloc_traits.h:328:13: error: ‘class std::vector<float, std::allocator<int> >’ has no member named ‘deallocate’; did you mean ‘_M_deallocate’?
{ __a.deallocate(__p, __n); }
~~~~^~~~~~~~~~
_M_deallocate
Я думаю, проблема в том, что C ++ не может выделить в памяти вектор целых чисел, но я не знаю почему ...