Last active
November 20, 2023 12:03
-
-
Save fish2000/7949ed279a6ce41302df371e1833f32c to your computer and use it in GitHub Desktop.
Revisions
-
fish2000 revised this gist
Mar 4, 2020 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6190,6 +6190,8 @@ A *polymorphic class* is a class that defines or inherits at least one virtual f ##### Example ```c++ class B { // GOOD: polymorphic class suppresses copying public: B(const B&) = delete; @@ -6211,6 +6213,8 @@ A *polymorphic class* is a class that defines or inherits at least one virtual f D d; f(d); ``` ##### Note If you need to create deep copies of polymorphic objects, use `clone()` functions: see [C.130](#Rh-copy). @@ -6238,6 +6242,8 @@ The compiler is more likely to get the default semantics right and you cannot im ##### Example ```c++ class Tracer { string message; public: @@ -6250,6 +6256,8 @@ The compiler is more likely to get the default semantics right and you cannot im Tracer& operator=(Tracer&&) = default; }; ``` Because we defined the destructor, we must define the copy and move operations. The `= default` is the best and simplest way of doing that. ##### Example, bad -
fish2000 revised this gist
Mar 4, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6165,6 +6165,8 @@ A *polymorphic class* is a class that defines or inherits at least one virtual f ##### Example, bad ```c++ class B { // BAD: polymorphic base class doesn't suppress copying public: virtual char m() { return 'B'; } @@ -6184,6 +6186,8 @@ A *polymorphic class* is a class that defines or inherits at least one virtual f D d; f(d); ``` ##### Example class B { // GOOD: polymorphic class suppresses copying -
fish2000 created this gist
Mar 4, 2020 .There are no files selected for viewing