Journal Articles
Browse in : |
All
> Journals
> CVu
> 116
(22)
All > Topics > Programming (877) Any of these categories - All of these categories |
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Seductive Tips
Author: Administrator
Date: 03 October 1999 13:15:34 +01:00 or Sun, 03 October 1999 13:15:34 +01:00
Summary:
Body:
A few weeks ago the following appeared on one of the C++ newsgroups. I want you to study it very carefully and then itemise all the reasons why you consider this apparently seductive idea to be extremely dangerous.
A Not So Obvious C++ Tip:
Define copy assignment operator out of copy constructor Typically copy assignment operator and copy constructor are closely related to one another. Both of them are expected to leave an object in a state of being a copy to another one. One can use this fact in order to simplify the task of defining the assignment operator out of the copy constructor, as shown below.
// Define copy assignment out of copy constructor. // DEFINE_ASS_BY_CTOR(ClassName) // To appear (only) within class definition. // Define copy assignment out of copy constructor. #define DEFINE_ASS_BY_CTOR(ClassName) \ ClassName & operator = (const ClassName & from) \ { \ assert (this && &(from)); \ assert (typeid (*this) == typeid (ClassName)); \ if (this == &(from)) \ return *this; \ ClassName::~ClassName(); \ new (this) ClassName (from); \ return *this; \ }
Notes:
More fields may be available via dynamicdata ..