pointer reference type

Posted by Codenotguru on Stack Overflow See other posts from Stack Overflow or by Codenotguru
Published on 2010-04-27T00:54:27Z Indexed on 2010/04/27 1:03 UTC
Read the original article Hit count: 442

Filed under:
|
|

I am trying to write a function that takes a pointer argument, modifies what the pointer points to, and then returns the destination of the pointer as a reference. I am gettin the following error: cannot convert int***' toint*' in return| Code:

#include <iostream>
using namespace std;
int* increment(int** i) { i++; return &i;}
int main() {
int a=24;
int *p=&a;
int *p2;
p2=increment(&p);
cout<<p2;
}

Thanks for helping!

© Stack Overflow or respective owner

Related posts about reference

Related posts about types