Using header <new>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonas Cord

    Using header <new>

    Hi, is it necessary to #include the standard header <new> in standard
    C++ when using dynamic memory management? Deitel & Deitel state that it
    is, but I have hardly ever seen it used.
    Thanks

    Jonas

  • msalters

    #2
    Re: Using header &lt;new&gt;


    Jonas Cord schreef:[color=blue]
    > Hi, is it necessary to #include the standard header <new> in standard
    > C++ when using dynamic memory management? Deitel & Deitel state that[/color]
    it[color=blue]
    > is, but I have hardly ever seen it used.[/color]

    No.

    HTH,
    Michiel Salters

    Comment

    • Chris Theis

      #3
      Re: Using header &lt;new&gt;


      "Jonas Cord" <cordjonas@yaho o.co.uk> wrote in message
      news:1115809262 .104485.187730@ g43g2000cwa.goo glegroups.com.. .[color=blue]
      > Hi, is it necessary to #include the standard header <new> in standard
      > C++ when using dynamic memory management? Deitel & Deitel state that it
      > is, but I have hardly ever seen it used.
      > Thanks
      >
      > Jonas
      >[/color]

      The answers is yes & no. If you take at look at the standard (3.7.3 ISO
      14882:2003(E)) you'll find that a program using new or delete is well formed
      without including the header <new>. However, refering to std::bad_alloc and
      std::size_t is ill formed unless the name was introduced by including the
      appropriate header file.

      HTH
      Chris


      Comment

      • Jonathan Mcdougall

        #4
        Re: Using header &lt;new&gt;

        > Hi, is it necessary to #include the[color=blue]
        > standard header <new> in standard
        > C++ when using dynamic memory management?
        > Deitel & Deitel state that it
        > is, but I have hardly ever seen it used.[/color]

        <new> contains:

        .. class bad_alloc
        .. set_new_handler ()
        .. new (nothrow)

        and several already global functions. If
        you don't use none of these three features,
        you don't need to include <new>.


        Jonathan

        Comment

        Working...