Is new() an operator or a function?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pallavi1983
    New Member
    • Oct 2007
    • 1

    #1

    Is new() an operator or a function?

    hi everyone
    i wanted to know that new() in c++ is a operator or a function?
    please send me the reply
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by pallavi1983
    hi everyone
    i wanted to know that new() in c++ is a operator or a function?
    please send me the reply
    new is an operator in c++.

    Raghu

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      I've changed the title of your thread to be a bit more descriptive (which actually increases the number of people who look at it!)

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Here's the straight dope in C++:

        1) new is an operator.

        2) the new operator calls

        [code=cpp]
        void* operator new(size_t arg);
        [/code]

        It is this function that you override. That is, you do not overload the new operator. Instead you overload the operator new() that's called by the new operator. (seriously, I'm not making this up).

        Comment

        • vinay253
          New Member
          • Oct 2007
          • 3

          #5
          Originally posted by gpraghuram
          new is an operator in c++.

          Raghu
          NEW is a operator in c++. it dont require any type casting and main important of new is you can initialise the memory with any value at the time of cration, its not possible with malloc or calloc or etc..

          Comment

          Working...