Yahoo Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

1. functors are class objects which overload operator(),
2. function pointers are pointer to function, eg: vtbl is a array of function pointers...
3. callback functions are function pointers passed as parameters of function, which can be called back when an event occurs...eg: when a thread is created,we send a callback function to be called when thread starts...

- lapak2009 December 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

THANKS

- ramesh.chettu20 December 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Ans. Functors are functions with a state. In C++ you can realize them as a class with one or more private members to store the state and with an overloaded operator () to execute the function. Functors can encapsulate C and C++ function pointers employing the concepts templates and polymorphism. You can build up a list of pointers to member functions of arbitrary classes and call them all through the same interface without bothering about their class or the need of a pointer to an instance. All the functions just have got to have the same return-type and calling parameters. Sometimes functors are also known as closures. You can also use functors to implement callbacks.
Function Pointers are pointers, i.e. variables, which point to the address of a function. You must keep in mind, that a running program gets a certain space in the main-memory. Both, the executable compiled program code and the used variables, are put inside this memory. Thus a function in the program code is, like e.g. a character field, nothing else than an address. It is only important how you, or better your compiler/processor, interpret the memory a pointer points to.
Function Pointers provide the concept of callback functions. A callback is done just like a normal function call would be done: You just use the name of the function pointer instead of a function name.

- smita December 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

thanx ..its a perfect answer..

- Anonymous January 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A Functor is a object which acts like a function. Basically, a class which defines operator().

class MyFunctor
{
public:
int operator()(int x) { return x * 2;}
}

MyFunctor doubler;
int x = doubler(5);

- karn January 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

could you please give, clear explaination of function call and function pointer call??????????

- raji May 22, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More