Reference pointer

#include <iostream>
using namespace std;
int& modpnt(int*& p)
return p;
int main()
int a=67;
int *pnt;
cout<<"Here pointer points to:"<<(int)pnt<<endl;
cout<<"here pointer points to:"<< modpnt(pnt)<<endl;
When i compile this programm it shows me the error that "In function int& modpnt(int*&):error:invalid intialisation of reference of type int& from expression of type int*"
First - please edit your post with code tags - the <> button on the right.

A Reference is slightly different to a pointer - try calling modpnt(const a&)

This says that the argument is a reference, which is not the same thing as pnt=&a; which takes the adrress of the variable a (a pointer).

I used const so that the function will not change the value of a.
Topic archived. No new replies allowed.