if " int*& ptr " is declared as a parameter of a function, what does it do?

for example:

findMax(int arr[], int n, int*& ptr)

Recommended Answers

All 2 Replies

int : integer
(int *) : pointer to integer
(int *)& : reference to pointer to integer

So, somewhere you have a pointer to an integer. int *p; Your function wants to play with it. findMax( ..., p ); Now p points to the largest integer in your array of integers. cout << "The largest is " << *p << ".\n"; Hope this helps.

thank you! this clarifies much confusion I was experiencing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.