作成中のカスタム クラスでベクトルを使用すると問題が発生します。これが私のコードです
vector<image> frames;
int i = 0;
while (i < n) {
image tempImage;
tempImage.read(fullname);
frames.push_back(tempImage);
}
image のコンストラクタは image() {}; です。
簡単なものが欠けていると確信していますが、それが何であるかわかりません。ここに私のエラーがあります
/usr/include/c++/4.2.1/ext/new_allocator.h:107:20: error: no matching constructor for initialization of 'image'
{ ::new(__p) _Tp(__val); }
^ ~~~~~
/usr/include/c++/4.2.1/bits/stl_vector.h:604:20: note: in instantiation of member function
'__gnu_cxx::new_allocator<image>::construct' requested here
this->_M_impl.construct(this->_M_impl._M_finish, __x);
^
video.cpp:50:10: note: in instantiation of member function 'std::vector<image, std::allocator<image> >::push_back'
requested here
frames.push_back(tempImage);
^
./image.h:25:4: note: candidate constructor not viable: 1st argument ('const image') would lose const qualifier
image(image &img);
^
./image.h:24:4: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
image();
^
In file included from video.cpp:1:
In file included from ./video.h:6:
In file included from /usr/include/c++/4.2.1/vector:73:
/usr/include/c++/4.2.1/bits/vector.tcc:252:8: error: no matching constructor for initialization of 'image'
_Tp __x_copy = __x;
^ ~~~
/usr/include/c++/4.2.1/bits/stl_vector.h:608:4: note: in instantiation of member function 'std::vector<image,
std::allocator<image> >::_M_insert_aux' requested here
_M_insert_aux(end(), __x);
^
video.cpp:50:10: note: in instantiation of member function 'std::vector<image, std::allocator<image> >::push_back'
requested here
frames.push_back(tempImage);
^
./image.h:25:4: note: candidate constructor not viable: 1st argument ('const value_type' (aka 'const image')) would
lose const qualifier
image(image &img);
^
./image.h:24:4: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
image();
^
./image.h:26:4: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
image(int rows, int columns);
^
2 errors generated.