Geeks Talk

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.

Function vs Operator

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 ?...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 08-06-2009
Junior Member
 
Join Date: Apr 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
sudeepa123 is on a distinguished road
Question Function vs Operator vs Macro

How do we compare and contrast between a function ,an operator and macro ?

Last edited by sudeepa123; 08-06-2009 at 06:02 AM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-06-2009
Expert Member
 
Join Date: May 2009
Location: Bangalore
Posts: 991
Thanks: 155
Thanked 420 Times in 201 Posts
rijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nicerijus is just really nice
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.
Reply With Quote
  #3 (permalink)  
Old 09-17-2009
Junior Member
 
Join Date: Jun 2008
Location: delhi
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
macmacmap is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 12:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved