Search
 
SCRIPT & CODE EXAMPLE
 

CPP

take a function argument

// C++ program to pass function as a
// pointer to any function
  
#include <iostream>
using namespace std;
  
// Function that add two numbers
int add(int x, int y)
{
    return x + y;
}
  
// Function that multiplies two
// numbers
int multiply(int x, int y)
{
    return x * y;
}
  
// Function that takes a pointer
// to a function
int invoke(int x, int y,
           int (*func)(int, int))
{
    return func(x, y);
}
  
// Driver Code
int main()
{
    // Pass pointers to add & multiply
    // function as required
    cout << "Addition of 20 and 10 is ";
    cout << invoke(20, 10, &add)
         << '
';
  
    cout << "Multiplication of 20"
         << " and 10 is ";
    cout << invoke(20, 10, &multiply)
         << '
';
  
    return 0;
}
Comment

function arguments

function createMenu({ title, body, buttonText, cancellable }) {
  // ...
}

createMenu({
  title: "Foo",
  body: "Bar",
  buttonText: "Baz",
  cancellable: true
});
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to declare a vector of int in c++ 
Cpp :: Fisher–Yates shuffle Algorithm c++ 
Cpp :: udo apt install dotnet-sdk-5 permission denied 
Cpp :: changing values of mat in opencv c++ 
Cpp :: cyclic array rotation in cpp 
Cpp :: c++ program to convert celsius to kelvin 
Cpp :: how to change the value of a key in hashmp in c++ 
Cpp :: c++ namespace example 
Cpp :: Integer Moves codeforces solution 
Cpp :: adddynamic ue4 c++ 
Cpp :: c++ get active thread count 
Cpp :: power in c++ 
Cpp :: string in c++ 
Cpp :: remove comments c++ 
Cpp :: c++ pop string from vector 
Cpp :: 344. reverse string c++ 
Cpp :: for auto c++ 
Cpp :: backtrack 
Cpp :: Split a number and store it in vector 
Cpp :: c++ preprocessor commands 
Cpp :: custom slider cpt wordpress theme 
Cpp :: C++ Vector Operation Delete Elements 
Cpp :: C++ Pointers to Structure 
Cpp :: C++ Class Template Declaration 
Cpp :: cpp compare strings 
Cpp :: rgb type def 
Cpp :: building native binary with il2cpp unity 
Cpp :: object inside class c++ 
Cpp :: how to type a vertical stack program c++ 
Cpp :: glUniform bool 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =