jweinst1
9/5/2016 - 5:33 AM

func pointer practice

func pointer practice

#include <iostream>

//sample struct for function pointer example
struct item {
	int i;
	char * s;
	bool b;
};
//sets the int of an item
item setint(item a, int elem){
	a.i = elem;
	return a;
}


int main() {
	typedef item (*call)(item, int);
	item t;
	call x = &setint;
	item f = (*x)(t, 5);
	std::cout << f.i << std::endl;
	//5
}