Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Function vs Operator within the C and C++ forums, part of the Software Development category; How do we compare and contrast between a function ,an operator and macro ?...
|
|||||||
|
|||
|
Re: Function vs Operator
Hi,
A macro just replaces the code assigned to it. Eg: # define geekinterview 999 , The code is substituted by the MACRO geekinterview If the macro defination go like kind of x++ and y++, it's better to use functions and avoid macros. Use typedef instead of macros (while pointer declarations). whereas function doesn't replace code but it performs what it is supposed to do. Operators are defined as operators by the language.Some operatorsare overloadable, others are not. Most operators do not create sequence points (although when overloaded, the overloaded versions are functions and do impose sequence points). The number of operands onwhich an operator operates is fixed and immutable. i think this will resolve u r query. If any .....Let me know.. Thanks, Riju. |
|
|||
|
Re: Function vs Operator
function:- separate section of code , written to remove redundancy of code , so we can use that function where ever we need to use that functionality.
operator:- operator is what which is previously defined to (or known to) compiler , compiler is aware of the operand associates with the operator.(n if violate then dr will be compilation error) Macro:-Marco is somehow like function (work on d same functionality as function do) but marco code get replace where even it is mention in code during pre-processing where as in function compiler execute the code and whenever there is a function can its jumps to function code area(memory). for small program macro is handy but if program size get bigger then its advisable to use function. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Difference between LIKE and = operator | ashalalaxmi2002 | SQL | 5 | 08-30-2008 02:28 AM |
| set operator | sunil_bisht | SQL | 1 | 08-27-2008 06:26 AM |
| set operator | sunil_bisht | SQL | 1 | 08-19-2008 08:15 AM |
| sizeof() operator | jaiprabuk | C and C++ | 9 | 08-10-2008 01:14 PM |
| Operator overloading | valireddy | C and C++ | 2 | 04-12-2008 07:34 AM |