Find the answer to your Linux question:
Results 1 to 3 of 3
Can anybody tell which header file contains new and delete operators?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2004
    Posts
    11

    new and delete operator


    Can anybody tell which header file contains new and delete operators?

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    I assume you are talking about C++...these are part of base C++. They aren't included in any additional files (require by #include<>), if that's what you want to know. Example:

    Code:
    sarumont@quark ~ $ cat blah.cpp
    #include<iostream>
    
    int main&#40;&#41;
    &#123;
            int *i = new int&#40;5&#41;;
            std&#58;&#58;cout << *i << std&#58;&#58;endl;
            delete i;
            return 0;
    &#125;
    
    sarumont@quark ~ $ g++ -Wall blah.cpp
    sarumont@quark ~ $ ./a.out
    5
    sarumont@quark ~ $
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    /dev/random
    Posts
    404
    On my system at work running Redhat 7.3, the path to the header for new is
    /usr/lib/gcc-lib/i386-glibc21-linux/egcs-2.91.66/include/new
    or
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/include/new

    Mind you, these are only DECLARATIONS..
    For the definitions, check out the source code of libstdc++...

    These files are internally (possibly recursively??) #included by one of the system headers - maybe iostream itself?
    Or, maybe the compiler by default includes them in all the sources?

    The same applies to the headers for the C++ ABI and RTTI functionality - you don't need to include them explicitly, yet their functionality is available in your code...
    The Unforgiven
    Registered Linux User #358564

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •