int do_sth(int a, int b, function<int(int, int)> binop) { // C++ - Like
return binop(a, b);
}
// function ask for void function with int param
void func ( void (*f)(int) );
// void function with int param :)
void print ( int x ) {
printf("%d
", x);
}
// pass print function to func
func( print )
// program to print a text
#include <iostream>
using namespace std;
// display a number
void displayNum(int n1, float n2) {
cout << "The int number is " << n1;
cout << "The double number is " << n2;
}
int main() {
int num1 = 5;
double num2 = 5.5;
// calling the function
displayNum(num1, num2);
return 0;
}
void myFunction(string fname) {
cout << fname << " Refsnes
";
}
int main() {
myFunction("Liam");
myFunction("Jenny");
myFunction("Anja");
return 0;
}
// program to print a text
#include <iostream>
using namespace std;
// display a number
void displayNum(int n1, float n2) {
cout << "The int number is " << n1;
cout << "The double number is " << n2;
}
int main() {
int num1 = 5;
double num2 = 5.5;
// calling the function
displayNum(num1, num2);
return 0;
}
void myFunction(string fname) {
cout << fname << " Refsnes
";
}
int main() {
myFunction("Liam");
myFunction("Jenny");
myFunction("Anja");
return 0;
}
// Liam Refsnes
// Jenny Refsnes
// Anja Refsnes