below you will find a code (that compiles/runs), which in brief invokes a function which allocates an array dynamically on the heap.
#include "stdafx.h"
#include <stdio.h>
class A
{
    public:
    A()
    {
        printf ( "constructor has been called !!! \n" );
    }
    ~A()
    {
        printf ( "destructor has been called !!! \n" );
    }
    char* f( void )
    {
        //char *data_raw = NULL;
        data_raw = NULL;
        data_raw = new char [ 20 ];
        for( int i = 0; i < 20; i++ )
        {
            data_raw[ i ] = '0';    
        }
        data_raw[  0 ] = 'h';
        data_raw[  1 ] = 'e';
        data_raw[  2 ] = 'l';
        data_raw[  3 ] = 'l';
        data_raw[  4 ] = 'o';
        data_raw[  5 ] = ' ';
        data_raw[  6 ] = 'w';
        data_raw[  7 ] = 'o';
        data_raw[  8 ] = 'r';
        data_raw[  9 ] = 'l';
        data_raw[ 10 ] = 'd';
        data_raw[ 11 ] = '!';
        return data_raw;
    } //data raw ptr-var is destroyed
    private:
        char *data_raw;
};
int  _tmain( int argc, _TCHAR* argv[] )
{
    char *data = NULL;
    printf( "data: %c", data );
    A a;
    data = a.f();
    delete [] data;  
    return 0;
}
My questions:
1) regarding destroying the memory allocated dynamically, should I use delete or delete [ ] ? both of them compile...
2) when I use the former ( delete ), the class destructor gets invoked, but not when I use delete [] ?
 
     
    