Solved

Difference between opeartor and function

Posted on 2004-04-25
5
178 Views
Last Modified: 2010-04-01
Hi,
does anybody have idea abt the difference in bettween opeartor and function in C/C++.

Thanks,
amit
0
Comment
Question by:agri_amit
5 Comments
 
LVL 5

Accepted Solution

by:
info_expert earned 25 total points
ID: 10915792
and operator behaves like function but a function does not behave like operator,

i.e.

when you call   :
cin>>a;

by default it is actually called:    >> as name of function and 'cin' and a are the parameters passsed.

0
 
LVL 12

Assisted Solution

by:stefan73
stefan73 earned 25 total points
ID: 10916346
Hi agri_amit,
> the difference in bettween opeartor and function in C/C++
(I assume you mean C++ only, you can't redefine/overload operators in C)

From the compiler viewpoint, there's not much of a difference. Operators are just functions with a bit of syntactical sugar.

ostream & operator<<( ostream & o, A& a ) {
    o << a.my_int ;
}

This one you could call as
cout << my_instance;

or as
operator<<(cout, my_instance);




Cheers,
Stefan
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now