Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C++ Programming

allocator.destroy()


Why does the value of the below int pointer not disappear after using
destroy:

        std::allocator<int> allo;

        int* ip;
        allo.construct(ip,777);
        std::cout << "*ip = " << *ip << std::endl;

        allo.destroy(ip);

        std::cout << "*ip = " << *ip << std::endl;

I get two prints with 777.

What do you think "destroy" does ?  What do you expect it to do ?

It's undefined in this case.  It might print 777 on your platform, it
might not on mine and it might melt the cpu on other platforms.

On 4 Juni, 23:14, Gianni Mariani <gi3nos@mariani.ws> wrote:

Did I read you post wrong? Because to me it seems like the call to
destroy is quite defined while the last line (where the pointer is
dereferenced) is undefined.

--
Erik Wikstrm

The second sentence refers to the code in the post - in particular the
second *ip.

> ... Because to me it seems like the call to
> destroy is quite defined while the last line (where the pointer is
> dereferenced) is undefined.

Yeah - it may be stated in an ambiguous way.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc