Operators vs Functions in C/C++
- by user356106
Someone recently asked me the difference between a C++ standard operator (e.g. new,delete,sizeof) and function (e.g. tan,delete, malloc). By "standard" I mean those provided by default by the compiler suite, and not user defined. Below were the answers I gave, though neither seemed satisfactory.
(1) An operator doesn't need any headers to be included to use it : E.g. you can have a call to new without including any headers. However, a function (say free() ) does need headers included, compulsorily.
(2) An operator is defined as such (ie as a class operator) somewhere in the standard headers. A function isn't.
Can you critique these answers and give me a better idea of the difference?