1

次のように、2 つの浮動小数点数の配列をベクトルに格納したいと思います。

float b_pt[16] = {-65.,-55.,-45.,-40.,-35.,-30.,-25.,-20.,20.,25.,30.,35.,40.,45.,55.,65.};
  float b_eta[25] =
  {-4.5,-4.25,-4.,-3.75,-3.5,-3.25,-3.,-2.75,-2.5,-2.25,-2.,-1.,0.,1.,2.,2.25,2.5,2.75,3.,3.25,3.5,3.75,4.,4.25,4.5};

vector<float[]> bins;
bins.push_back(b_pt);
bins.push_back(b_eta);

しかし、次のエラーが発生します。

g++ -g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings -pthread -m64 -I/opt/local/root-v5-34-00/include -L/opt/local/root-v5-34-00/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lpthread -Wl,-rpath,/opt/local/root-v5-34-00/lib -lm -ldl -MMD -MP  -c -o test.o test.cpp
test.cpp: In function ‘int main()’:
test.cpp:31: error: no matching function for call to ‘std::vector<float [], std::allocator<float []> >::push_back(float [16])’
/usr/include/c++/4.2.1/bits/stl_vector.h:600: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = float [], _Alloc = std::allocator<float []>]
test.cpp:32: error: no matching function for call to ‘std::vector<float [], std::allocator<float []> >::push_back(float [25])’
/usr/include/c++/4.2.1/bits/stl_vector.h:600: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = float [], _Alloc = std::allocator<float []>]
/usr/include/c++/4.2.1/bits/stl_vector.h: In destructor ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = float [], _Alloc = std::allocator<float []>]’:
/usr/include/c++/4.2.1/bits/stl_vector.h:202:   instantiated from ‘std::vector<_Tp, _Alloc>::vector(const _Alloc&) [with _Tp = float [], _Alloc = std::allocator<float []>]’
test.cpp:30:   instantiated from here
/usr/include/c++/4.2.1/bits/stl_vector.h:123: error: invalid use of array with unspecified bounds
/usr/include/c++/4.2.1/bits/stl_construct.h: In function ‘void std::__destroy_aux(_ForwardIterator, _ForwardIterator, std::__false_type) [with _ForwardIterator = float (*)[]]’:
/usr/include/c++/4.2.1/bits/stl_construct.h:155:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = float (*)[]]’
/usr/include/c++/4.2.1/bits/stl_construct.h:182:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_T2>) [with _ForwardIterator = float (*)[], _Tp = float []]’
/usr/include/c++/4.2.1/bits/stl_vector.h:271:   instantiated from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = float [], _Alloc = std::allocator<float []>]’
test.cpp:30:   instantiated from here
/usr/include/c++/4.2.1/bits/stl_construct.h:121: error: cannot increment a pointer to incomplete type ‘float []’

これを行う方法についてアドバイスしてください!

4

1 に答える 1