home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.os.msdos.programmer:9267 comp.lang.c++:13527
- Newsgroups: comp.os.msdos.programmer,comp.lang.c++
- Path: sparky!uunet!usc!rpi!ghost.dsi.unimi.it!cdc835.cdc.polimi.it!gin503
- From: gin503@cdc835.cdc.polimi.it (Maurizio Sartori Masar)
- Subject: BC++ far new(): Results
- Date: Fri, 11 Sep 1992 09:04:41 GMT
- Nntp-Posting-Host: cdc835.cdc.polimi.it
- Organization: C.d.C., Politecnico di Milano
- Sender: netnews@cdc835.cdc.polimi.it (News Admin)
- Message-ID: <gin503.716202281@cdc835>
- Lines: 63
-
-
- Thanks to all who replyed.
-
-
- This is what I've discovered about using 'new' in small memory model with
- Borland C++.
-
-
- /***************************************/
- /* Uncomment the Case you want examine */
- /***************************************/
-
- // // Case | Class | New | Result
- // // | Def | Call |
- // // ----------------------------------------
- //#define FOO_DEF FOO // 1 | near | |
- //#define FOO_NEW FOO // 1 | | near | near alloc
- //#define FOO_DEF far FOO // 2 | far | |
- //#define FOO_NEW FOO // 2 | | near | near alloc
- //#define FOO_DEF FOO // 3 | near | |
- //#define FOO_NEW far FOO // 3 | | far | Compile error
- //#define FOO_DEF far FOO // 4 | far | |
- //#define FOO_NEW far FOO // 4 | | far | far alloc
- //#define FOO_DEF far FOO // 5 | far | |
- //#define FOO_NEW (far FOO) // 5 | | far | Compile Error
-
- #include <stdio.h>
-
- class FOO_DEF
- {
- char cFoo [10000];
- }; /* end-class FOO */
-
- int main ()
- {
- FOO far * alpFoo [10];
-
- for (int i = 0; i < 10; i++)
- {
- alpFoo[i] = new FOO_NEW;
-
- printf ("Array %i is %Fp\n", i, alpFoo[i]);
- }
- return (0);
- }
-
-
- /****************************/
-
- Results: If you declare a class as 'far', you can alloc it 'near' or 'far'
- as you want.
- If you declare it 'near' you must alloc it 'near'.
-
- Note: Don't use parentesis with the 'new' operator: Compiler error.
-
-
- Maurizio
-
- --
- )) )) )) )))))) )) ))))))) Maurizio Sartori Masar
- )))))))) )) )) )))))) )) )) )) )) gin503@cdc835.cdc.polimi.it
- )) )) )) )))))))) )) )))))))) )))))) Politecnico di Milano
- )) )) )) )) )))))) )) )) )) )) ITALY
-