Click here to Skip to main content
15,905,420 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Window from resource Pin
Erik Funkenbusch31-Aug-00 12:17
Erik Funkenbusch31-Aug-00 12:17 
GeneralTab key is not working in OCX control -- URGENT Pin
Abdul Kareem31-Aug-00 4:49
Abdul Kareem31-Aug-00 4:49 
GeneralRe: Tab key is not working in OCX control -- URGENT Pin
Igor Chouvalov31-Aug-00 6:07
Igor Chouvalov31-Aug-00 6:07 
GeneralRe: Tab key is not working in OCX control -- URGENT Pin
Abdul Kareem31-Aug-00 7:27
Abdul Kareem31-Aug-00 7:27 
GeneralICommandWithParameters implementation code Pin
hongdongsuk31-Aug-00 0:58
hongdongsuk31-Aug-00 0:58 
Generaloverriding new/delete Pin
Walter Gildersleeve30-Aug-00 21:24
Walter Gildersleeve30-Aug-00 21:24 
GeneralRe: overriding new/delete Pin
Tim Deveaux31-Aug-00 14:00
Tim Deveaux31-Aug-00 14:00 
GeneralRe: overriding new/delete Pin
Tim Deveaux3-Sep-00 3:49
Tim Deveaux3-Sep-00 3:49 
Here's a generic test, for discussion purposes...

#include <stdio.h>
#include <malloc.h>
  
struct test{
    int a;
    int b;
    int c;
  
    void * operator new(size_t);
    void operator delete(void*);
  
    void * operator new[] (size_t); 
    void operator delete[] (void*);
};
  
void * test::operator new(size_t sz)
{
    return malloc(sz);
}
   
void __cdecl test::operator delete(void* t)
{
    free(t);
}
   
void * test::operator new[](size_t sz)
{
    return malloc(sz);
}
   

void test::operator delete[](void* t)
{
    free(t);
}
   
   
int main(int argc, char* argv[])
{
    printf("Hello World!\n"); 
  
    // calls t::new & t::delete
    test* t = new test;
    delete t;
   
    // calls t::new[] & t::delete[]
    t = new test[20];
    delete []t;
   
    // calls global new and delete
    int * p = new int;
    delete p;
   
    return 0;
}


This works as 'expected' on both Borland CPP Builder 4 and MS VC6, but leaves me with another question - I didn't expect to be able to provide an operator delete[] at class scope! Interestingly, if I try to scope the new and delete of the test class (e.g. test::new), I get errors - Borland simply gives 'Expression syntax', whereas VC6 says 'operator xxx must be globally qualified'.

What gives?
GeneralVB / VC++ question Pin
Danny30-Aug-00 21:17
Danny30-Aug-00 21:17 
GeneralRe: VB / VC++ question Pin
HP31-Aug-00 1:07
HP31-Aug-00 1:07 
GeneralRe: VB / VC++ question Pin
jschacker1-Sep-00 10:45
jschacker1-Sep-00 10:45 
GeneralGet Binary TimeZone Info from Registry Pin
Lynda Brenock30-Aug-00 19:39
sussLynda Brenock30-Aug-00 19:39 
GeneralRe: Get Binary TimeZone Info from Registry Pin
HP31-Aug-00 1:00
HP31-Aug-00 1:00 
GeneralRe: Get Binary TimeZone Info from Registry Pin
lynda31-Aug-00 12:04
lynda31-Aug-00 12:04 
GeneralHyperlink Pin
Eq30-Aug-00 18:04
Eq30-Aug-00 18:04 
GeneralRe: Hyperlink Pin
Oleg Zhuk30-Aug-00 22:53
Oleg Zhuk30-Aug-00 22:53 
Generalannoying button border Pin
philippe dykmans29-Aug-00 0:16
philippe dykmans29-Aug-00 0:16 
GeneralRe: annoying button border Pin
philippe dykmans30-Aug-00 23:53
philippe dykmans30-Aug-00 23:53 
Generaltree controls in unicode... Pin
lauren28-Aug-00 21:03
lauren28-Aug-00 21:03 
GeneralCursor pointer color Pin
sunny28-Aug-00 15:54
sunny28-Aug-00 15:54 
GeneralRe: Cursor pointer color Pin
Ezz Khayyat29-Aug-00 3:46
professionalEzz Khayyat29-Aug-00 3:46 
General*** Retriving Rows of Data from Access Tables ** Pin
Steve Lai28-Aug-00 15:40
Steve Lai28-Aug-00 15:40 
GeneralRe: *** Retriving Rows of Data from Access Tables ** Pin
lauren28-Aug-00 21:07
lauren28-Aug-00 21:07 
GeneralRe: *** Retriving Rows of Data from Access Tables ** Pin
Steve Lai29-Aug-00 10:39
Steve Lai29-Aug-00 10:39 
GeneralRe: *** Retriving Rows of Data from Access Tables ** Pin
lauren30-Aug-00 3:09
lauren30-Aug-00 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.