C++ is not C# - these two forms have different effects
{
A v = A(9);
A *w = new A(8);
}
The first one constructs a temporary A and assigns it to v. Constructor A(int) is called exactly once, and when v goes out of scope, ~A is called.
The second one allocates an A-sized piece of memory, constructs a temporary A, assigns it to that piece of memory, and sets w to point to it. Constructor A(int) is called exactly once, but when w goes out of scope, ~A is not called. The only destructor that would get called here is the one for type A*, and A* isn't a class so either there isn't one, or there is one that does nothing. Either way it isn't what you want.
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 )
Sunday, October 9, 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)