-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
invalidThis doesn't seem rightThis doesn't seem right
Description
Problem:
Missing function name in Data.xml for the call func_ptr_arr[1]();
in Data.xml.
Solution:
Gather the missing information during runtime and instantiate the dummy call accordingly.
Sample Code:
#include <iostream>
void a(){
std::cout << "a" << std::endl;
}
void b(){
std::cout << "b" << std::endl;
}
int main(){
// declare array of function pointers
void (*func_ptr_arr[2])() = {a, b};
// call function b
func_ptr_arr[1]();
}
More advanced sample code:
#include <iostream>
void a(){
std::cout << "a" << std::endl;
}
void b(){
std::cout << "b" << std::endl;
}
int main(){
// declare array of function pointers
void (*func_ptr_arr[2])() = {a, b};
// get random index
srand((unsigned)time(0));
int i = rand() % 2;
std::cout << "i: " << i << std::endl;
// call function
func_ptr_arr[i]();
}
``
Metadata
Metadata
Assignees
Labels
invalidThis doesn't seem rightThis doesn't seem right