Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

function as argument in another function in c++

#include <bits/stdc++.h>
using namespace std;

bool compare(int a, int b)
{
    return a > b;
}

void ans(int x, int y, bool (&func)(int a, int b))
{
    (func(x, y)) ? cout << x << " is bigger than" << y : cout << y << " is bigger than " << x << endl;
}

int main()
{
    ans(10, 20, compare);

    return 0;
 
PREVIOUS NEXT
Tagged: #function #argument #function
ADD COMMENT
Topic
Name
5+6 =