With this setup (two constructors, a copy constructor and the destructor)
class A {
A() {...}
A(int i) {...}
A(const A &a) {...}
~A() {...}
};
{
A c = A(11);
}
results in one call to the int constructor and one call to the destructor, whereas
{
A d;
d = A(11);
}
results in one call to the no-argument constructor, then one call to the int constructor when the temporary object is created, then a call to the destructor when its statement is complete; finally another destructor call when d goes out of scope.
NB btw that although both these forms look like they have an assignment in them, because it's in a definition, an assignment is not actually performed (and any assignment operator is not called). This situation counts as an initialisation not an assignment.
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Monday, October 10, 2011
Followers
Blog Archive
-
▼
2011
(80)
-
▼
October
(19)
- Perl mkdir, make_path and mkpath
- Perl and large integers
- readdir
- Combo box dropdown failure
- CreateProcess
- Pointers to member functions
- Perl system and synchronicity
- AAD and AAM
- Endianness
- Astronomy sky diagrams and photos often have a lit...
- Giving up smoking
- Constructors, temporary objects and initialisation
- new and constructors
- Choice of language
- argv and argc
- C++ static member functions
- do while is not a loop
- C++ structs
- mingw maximum file name length
-
▼
October
(19)