home *** CD-ROM | disk | FTP | other *** search
- //******** Listing 5 ********************** NEW.CPP *****
- // NEW.CPP : simple demonstration of `new' and `delete'
- // (c) C Gazette. See Listing 1 for usage.
- //*******************************************************
-
- #include <stdio.h>
- #include "object.hpp"
-
- main()
- {
- object X('X');
- puts("constructor for X was just called");
- object* op = new object('Y'); // Dynamic Object Creation
- puts("constructor for Y was just called");
- delete op; // Dynamic Object Destruction
- puts("destructor for Y was just called");
- puts("destructor for X will now be called");
- }
-
-