c++ - What happens when an object is left uninitialized during a copy constructor or in a assignment operator? -


suppose have vector object 1 of attributes , do't initialize in copy constructor, happen then? if other object does't have default constructor, happen?

suppose have vector object 1 of attributes , do't initialize in copy constructor, happen then?

i suppose pertaining initializing @ constructor initializer list. if so, default constructor called, seem have answered here...

also if other object does't have default constructor, happen?

your program not run. more specifically, compiler shoot out error, indicating you're trying (or implicitly trying) use object's non-existing or inaccessible constructor. try see self ;).

a way (read: not the way) get-around these types of objects have them dynamically allocated, is, use std::unique_ptrs of them. in way, delay construction when necessary arguments have been obtained. better way though, if can , should, augment or wrap class of object incorporate move semantics. move semantics, eliminate "delayed-construction-because-i-don't-yet-have-the-necessary-arguments" problem. default constructor leave object's state uninitialized, i.e. unusable re-initializable using move/copy constructor. great example std::thread.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -