UrbanPro
true

Take BSc Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

C++: Passing A Function As an Argument

Ashutosh Singh
23/12/2017 0 0

#include
using namespace std;

int sum(int a,int b)
{
   return a+b;
}
void f2(int (*f)(int,int),int a,int b) //'*f' is a POINTER TO A FUNCTION whose RETURN TYPE is                                                           //'int' and arg type (int,int)  . Here, '*f' is FORMAL PARAMETER
{                                                                
  cout<<sum(a,b)<<endl;
}
int main()
{   int (*p1)(int,int)=∑          //Here, '*pf1' is ACTUAL PARAMETER
    f2(sum,10,20);                         //NAME OF A FUNCTION IS ITSELF A POINTER TO ITSELF
    f2(p1,20,79);
    return 0;

}

0 Dislike
Follow 3

Please Enter a comment

Submit

Other Lessons for You

Phishing
Phishing: Sam received an email “Congratulations. . .You have won a Lottery!!!” Now, wasn’t that tempting..l The message said: It meant that he has won the lottery. ‘ The message...

Student Project Development: How To Go About It?
A lot of students (count me as well) in their final year of IT course are confused and overwhelmed about their Project development. Final Year IT Projects are a crucial milestone in every IT students educational...

Understanding Big Omega (?), Big Theta (?), Small Oh (o) And Small Omega (?) Notations
How to describe Big Omega(Ω) ? If run time of an algorithm is of Ω(g(n)), it means that the running time of the algorithm (as n gets larger) is at least proportional to g(n). Hence it helps...

How To Prepare For Any Exam?
1. Prepare mentally yourself to give an exam. 2. Know the benifit of passing the exam it encourages you to do your best. 3. Never think about failure. 4. Be confident. 5. Watch and solve old papers. 6....
M

Mohit S.

1 0
0

Rule Of Sign
1. Rule of sign solving is known as VBODMAS: V stands for "Vinculum" or "Bar" B stands for "Bracket" (order as small,medium,big) O stands for "Of" D stands for "Divisibility" M stands for "multiplication" A...
M

Mohit S.

1 0
0

Looking for BSc Tuition ?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for BSc Tuition Classes?

The best tutors for BSc Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BSc Tuition with the Best Tutors

The best Tutors for BSc Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more