TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CHRIS ULLIOTT
from: THOMAS MAEDER
date: 1997-05-03 17:10:00
subject: the new command

CU> Can someone please explain the difference of the following :
CU> CStringArray strMyArray;
CU> OR
CU> CStringArray *pstrMyArray = new CStringArray;
Both have an object constructed and declare and initialize a  variable
to refer to it.
The differences are:
- the place where the memory for the object is allocated:  the  second
declaration  allocates the required amount of memory for the object in
a "dynamic memory area", the first one (assuming the declaration is in
a function/method body) on the stack.
-  the  lifetime  of  the  object: the object constructed by the first
declaration lives until the variable goes out of scope (i.e. until the
end  of  the  surrounding block); the object constructed by the second
declaration lives until it is explicitly destructed.
Thomas
---
 þ MM 1.0 #0113 þ FIRE DEPARTMENT - You set 'em, we wet 'em!!
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.