Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ function as param

int do_sth(int a, int b, function<int(int, int)> binop) { // C++ - Like
    return binop(a, b);
}
Comment

c++ function as paramter

// 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 )
Comment

C++ Function with Parameters

// 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;
}
Comment

c++ function parameters

void myFunction(string fname) {
  cout << fname << " Refsnes
";
}

int main() {
  myFunction("Liam");
  myFunction("Jenny");
  myFunction("Anja");
  return 0;
}
Comment

C++ Function with Parameters

// 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;
}
Comment

C++ Function Parameters

void myFunction(string fname) {
  cout << fname << " Refsnes
";
}

int main() {
  myFunction("Liam");
  myFunction("Jenny");
  myFunction("Anja");
  return 0;
}

// Liam Refsnes
// Jenny Refsnes
// Anja Refsnes
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ output current timestamp 
Cpp :: quick sort 
Cpp :: getline 
Cpp :: find in unordered_map c++ 
Cpp :: c++ clip values 
Cpp :: Visual studio code include path not working c++ 
Cpp :: cin exceptions c++ 
Cpp :: c++ #include 
Cpp :: how to concatenate two vectors in c++ 
Cpp :: array of Methods c++ 
Cpp :: cpp #include "" < 
Cpp :: two elements with difference K in c++ 
Cpp :: long pi in c++ 
Cpp :: polymorphism in c++ 
Cpp :: c++ array pointer 
Cpp :: c++ inheritance constructor 
Cpp :: stack class implementation to file unix-style in c++ 
Cpp :: trie code cpp 
Cpp :: sum of first 100 natural numbers 
Cpp :: draw line sfml 
Cpp :: c++ recorrer string 
Cpp :: intlen in c++ 
Cpp :: minheap cpp stl 
Cpp :: closing a ifstream file c++ 
Cpp :: how to print an array in cpp in single line 
Cpp :: executing an opencv c++ code 
Cpp :: order 2d array in c++ 
Cpp :: Program to find GCD or HCF of two numbers c++ 
Cpp :: flutter text direction auto 
Cpp :: remove elements from vector 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =