I understand that the compiler will not generate a default copy of ctor if copy ctor is declared private in the class.
But can someone explain why the compiler does this?
What happens if copy ctor is declared protected? Will the compiler provide a default copy of ctor?
What happens if copy ctor is declared private but has a definition, for example. foo (const & obj) {}
, ( , ), , ctor. , , , , ( , , , ).
, ctor, , ( , ), , . ctor , , , , ( , , , , - ).
, , . (//) .
, , . , , .
, . .
$12/1 - " (12.1), (12.8) (12.4) . [ : , . , . [...]"
, , , , .
. , / , .
struct A{ A(){} private: A(A const &){} }; int main(){ A a1; A a2(a1); // direct initialization, error A a3 = a1; // copy initialization, error }
, . , (, ) .
Source: https://habr.com/ru/post/1767759/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1767754/warning-incompatible-objective-c-types-assigning-superclass-to-subclass&usg=ALkJrhi1x1Dw6q3yYVvVqTytrrB6uG89xQweird initialization behavior in C ++ - c ++A few questions about Ruby on Rails - ruby | fooobar.comjQuery Quicksand: CSS applied after loading JS causes abrupt behavior - jqueryQWidget :: setLayout error: attempt to install QLayout [...], which already has a layout - qtFind Duplicate PDF Files - pdfCSS фальшивый HR с фоновым изображением - cssHow to interpret a visual studio column? - c ++jQuery: grouping related elements - javascriptDon't understand date format in mysql like 1286066935 - UserCake - dateAll Articles