hooshdar3 wrote: |
---|
"+I got the idea from reading Herbet Shieldt's text that copy constructor is optional.true?" |
|
|
Scott Meyers wrote: |
---|
"NamedObject declares neither copy constructor nor copy assignment operator, so compilers will generate those functions (if they are needed). " |
Framework (2534) Jun 27, 2012 at 3:29pm hooshdar3 wrote: "+I got the idea from reading Herbet Shieldt's text that copy constructor is optional.true?" His books normally contain bad practices; be wary. As for the copy-constructor begin optional, the compiler has the last say, because the compiler will implicitly create its own copy-constructor only if its use is required. For instance: This code will generate a copy-constructor: 1 2 3 4 5 6 7 8 9 struct Object { int a_; }; int main() { Object a_, b_(a_); } Since b_ depends on the state of a_, the compiler will generate a copy-constructor for b_ but not a_, because a_ didn't require the use of the copy-constructor. Scott Meyers wrote: "NamedObject declares neither copy constructor nor copy assignment operator, so compilers will generate those functions (if they are needed). " Wazzak |