Answers for "how to reference a pointer in c++"

C++
3

Function pointer C++

void one() { cout << "Onen"; }
void two() { cout << "Twon"; }


int main()
{
	void (*fptr)(); //Declare a function pointer to voids with no params

	fptr = &one; //fptr -> one
	*fptr(); //=> one()

	fptr = &two; //fptr -> two
	*fptr(); //=> two()

	return 0;
}
Posted by: Guest on July-30-2020

Code answers related to "how to reference a pointer in c++"

Browse Popular Code Answers by Language