home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!hcla!jyc
- From: jyc@hcla.com (Joy Chhugani)
- Subject: new and delete in MFC and BorlandC
- Message-ID: <1992Dec23.230359.15065@hcla.uucp>
- Sender: jyc@hcla.uucp (Joy Chhugani)
- Organization: HCL America, Inc.,
- Date: Wed, 23 Dec 1992 23:03:59 GMT
- Lines: 53
-
-
-
- I am using Microsoft's MFC with Borland's C++ 3.1 IDE.
-
- This is a rough sketch of a class that I have -
-
- class Foo
- {
- private:
- CPoint *pts;
- ...
-
- public:
- Foo(const CPoint init[], short num);
-
- virtual
- ~Foo(void)
- {
- delete [] pts; // <------------- ::operator delete
- }
- ...
- ...
- };
-
- Foo::Foo(const CPoint init[], short num)
- {
- if (pts = new CPoint[num]) // <------------- _vector_new
- {
- for (short i = 0; i < num ; i++)
- pts[i] = init[i];
- }
- }
-
- The problem is that MFC's overloaded global operators new and delete
- are incompatible with BorlandC's internal memory allocation functions.
-
- In the Foo constructor the pts member points to an array allocated by
- "_vector_new" which is presumably an internal BorlandC function.
-
- In the destructor surprisingly the MFC overloaded global operator delete
- functions gets called. This does some memory usage check which fails.
-
- Has anybody encountered this problem or am I doing something that is
- wrong ? Any workarounds, solutions, suggestions etc. are welcome.
-
- Thanks in advance for the replies.
-
-
- --
- Joy Chhugani
- jyc@hcla.com
- uunet!hcla!jyc
-
-