Chciałbym przechowywać obiekty w liście w C++ tak, jak w ArrayList w Javie. Tworzę więc sobie:
std::vector<Aktywa> zbiorAktywow;
i kiedy próbuję wykonać polecenie zbiorObiektow.push_back(aktywa); to dostaję dziwny błąd:
In file included from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/i686-w64-mingw32/bits/c++allocator.h:33:0,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/allocator.h:46,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/string:41,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/locale_classes.h:40,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/ios_base.h:41,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/ios:42,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/ostream:38,
from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/iostream:39,
from C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\main.cpp:1:
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Aktywa; _Args = {const Aktywa&}; _Tp = Aktywa]':
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/alloc_traits.h:475:4: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = Aktywa; _Args = {const Aktywa&}; _Tp = Aktywa; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<Aktywa>]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_vector.h:943:30: required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Aktywa; _Alloc = std::allocator<Aktywa>; std::vector<_Tp, _Alloc>::value_type = Aktywa]'
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Portfel.cpp:24:13: required from 'Portfel<Aktywa>::Portfel() [with Aktywa = Aktywa]'
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\main.cpp:11:21: required from here
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/ext/new_allocator.h:136:4: error: invalid new-expression of abstract class type 'Aktywa'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Portfel.cpp:1:0,
from C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\main.cpp:4:
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Aktywa.hpp:6:7: note: because the following virtual functions are pure within 'Aktywa':
class Aktywa{
^~~~~~
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Aktywa.hpp:14:24: note: virtual double Aktywa::symulujWartosc(int)
virtual double symulujWartosc(int)=0; // metoda do obliczania wartości aktywa po pewnym czasie
^~~~~~~~~~~~~~
In file included from C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/vector:62:0,
from C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Portfel.cpp:2,
from C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\main.cpp:4:
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_construct.h: In instantiation of 'void std::_Construct(_T1*, _Args&& ...) [with _T1 = Aktywa; _Args = {Aktywa}]':
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_uninitialized.h:83:18: required from 'static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<Aktywa*>; _ForwardIterator = Aktywa*; bool _TrivialValueTypes = false]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_uninitialized.h:134:15: required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<Aktywa*>; _ForwardIterator = Aktywa*]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_uninitialized.h:289:37: required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<Aktywa*>; _ForwardIterator = Aktywa*; _Tp = Aktywa]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_uninitialized.h:311:2: required from '_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = Aktywa*; _ForwardIterator = Aktywa*; _Allocator = std::allocator<Aktywa>]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/vector.tcc:426:6: required from 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const Aktywa&}; _Tp = Aktywa; _Alloc = std::allocator<Aktywa>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Aktywa*, std::vector<Aktywa, std::allocator<Aktywa> > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = Aktywa*]'
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_vector.h:948:21: required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Aktywa; _Alloc = std::allocator<Aktywa>; std::vector<_Tp, _Alloc>::value_type = Aktywa]'
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\Portfel.cpp:24:13: required from 'Portfel<Aktywa>::Portfel() [with Aktywa = Aktywa]'
C:\Users\Jan\CLionProjects\EwidencjaOszczednosci\main.cpp:11:21: required from here
C:/PROGRA~2/MINGW-~1/I686-7~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/7.2.0/include/c++/bits/stl_construct.h:75:7: error: invalid new-expression of abstract class type 'Aktywa'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mingw32-make.exe[3]: *** [CMakeFiles\EwidencjaOszczednosci.dir\build.make:62: CMakeFiles/EwidencjaOszczednosci.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:67: CMakeFiles/EwidencjaOszczednosci.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:79: CMakeFiles/EwidencjaOszczednosci.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: EwidencjaOszczednosci] Error 2
Czym to może być spowodowane? Jak to naprawić?