home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / mswindo / programm / win32 / 1838 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  1.5 KB

  1. Path: sparky!uunet!pmafire!mica.inel.gov!ux1!news.byu.edu!hamblin.math.byu.edu!sol.ctr.columbia.edu!usc!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!news.aero.org!Aero.org!slewis
  2. From: slewis@Aero.org (Steven Lewis)
  3. Newsgroups: comp.os.ms-windows.programmer.win32
  4. Subject: Re: MSC++ problems with override delete
  5. Date: 6 Nov 1992 16:18:31 GMT
  6. Organization: The Aerospace Corporation
  7. Lines: 36
  8. Distribution: world
  9. Message-ID: <1de5snINN1im@news.aero.org>
  10. References: <1dbi2gINNpo6@news.aero.org>
  11. NNTP-Posting-Host: antares.aero.org
  12.  
  13. In article <1dbi2gINNpo6@news.aero.org>, slewis@aero.org (Steven Lewis) writes:
  14. |> 
  15. |>   Microsoft C gives me errors when I try to override the delete
  16. |> operator - the code fragment below accepts overriding new with no
  17. |> difficulty but gives errors on foo::delete. Borland, Zortech,
  18. |> Sun C++, gnu and Think C all think the syntax below is acceptable.
  19. |> 
  20. |> #include <stdio.h>
  21. |> 
  22. |> extern void *my_alloc(size_t Size);
  23. |> extern void my_free(void *Data);
  24. |> 
  25. |> class foo
  26. |> {
  27. |>     void* operator new(size_t objSize);
  28. |>     void  operator delete( void* objStorage);
  29. |> };
  30. |> 
  31. |> 
  32. |> void *foo::operator new(size_t objSize)
  33. |> {
  34. |>     ObjectD *TheObject;
  35. |>     TheObject = (ObjectD *)my_alloc(objSize);
  36. |>     return(TheObject);
  37. |> }
  38. |> 
  39. |> 
  40. |> void foo::operator delete( void *objStorage)
  41. |> {
  42. |>     my_free(objStorage);
  43. |> }
  44. |> 
  45.  
  46. Actually I tested the above code and it WORKS! It fails when I
  47. name the class ObjectD rather than foo - this is name I use.
  48. What is the conflict with ObjectD??
  49.