Say I have a stl vector containing a class like "xx". xx is abstract. I ran into a problem when the compiler does not allow me to "instantiate" when I do something like the following:
std::vector<xx> victor; void pusher(xx& thing) { victor.push_back(thing); } void main() { ; }
I guess this is because the copy constructor must be called. I ran into this problem by storing xx * in a vector, not in xx. Is there a better solution? What is it?
push_back, . , , , .
push_back
, , boost loki.
, (, , ), , STL, , , . , - . , , slicing.
std::vector ( STL ) . , , . std::vector . , , , ( , , , , , , - boost:: noncopyable, , ).
Source: https://habr.com/ru/post/1714801/More articles:Showing JScrollBar - javato create an array from a txt file - pythonld-linux - specify exit codes - linuxpywikipedia bot with https and http authentication - pythonstore file in NSDocumentDirectory iPhone - iphoneHow to read one BIT in a byte array? - arraysHow to combine remixes in Swing? - javaArray Constants in Excel - vbaNeed help refactoring my python script - pythonHow to effectively combine two hashes in Ruby C API? - cAll Articles