Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

aray of functions in c++

// create array of functions

void a() {
	std::cout << "a
";
}

void b() {
	std::cout << "a
";
}

void c() {
	std::cout << "a
";
}

void d() {
	std::cout << "a
";
}


int main (void) {
	// array of functions
	void (*funcs[4])() = {a, b, c, d};
  	//call the first element of the array
	(*funcs[0])(); // output: "a
"
  
	return 0;
}
 
PREVIOUS NEXT
Tagged: #aray #functions
ADD COMMENT
Topic
Name
6+2 =