c++


Declaring reference to a pointer


I am trying to declare a reference variable to a pointer.
#include<iostream>
using namespace std;
int main()
{
int m = 10;
int *p = &m;
int & ref = p; // this is showing error
}
I am reading a c++ book and in the book i saw this code, but this is showing an error.
It is supposed to set ref as a reference variable to point to pointer p and in turn point to m.
You are missing the asterisk * at the reference to pointer declaration:
int *p = &m;
int *&ref = p;
#include<iostream>
using namespace std;
int main()
{
int m = 10;
int *p = &m;
int *& ref = p; //read from right to left,so *& is a refrence to pointer
}

Related Links

Using an Array of pointers to copy a PPM Image
Avoiding virtual function calls in a computational graph
Null session pipes example, write access
Why does adding x + 1 skip 10?
Errors in prototype in C++ in XCode
C++ unordered set issue with struct hash [duplicate]
How to add cyclomatic complexity to sonar-cxx?
A pointer that can point to anywhere, how to determine if “delete” can be safely called on it?
Input will be floating value and program return whole part and decimal value
OpenDnp3 crosscompile tgo moxa UC8162LX segmentation fault at: epoll_reactor.hpp
Writing Memory to Process
Reading string from file
Is this a reasonably written test for a college 100-level software class midterm? [closed]
Wow64GetThreadContext error invalid parameter
Qt/C++ - Set background of disabled button?
Trouble with classes and adding objects

Categories

HOME
sql-server-2005
node-red
google-cloud-kms
jboss-eap-6
inform7
protege
playframework-2.5
postgis
vbulletin
astyle
salt-stack
react-boilerplate
selenium-rc
xlwings
cdb
workspace
preview
http-caching
akka-stream
ebcdic
cropper
pywavelets
inversifyjs
fread
infowindow
uwamp
tornado-motor
netbanx-api
bootstrapping
userfrosting
sqlcmd
each
angular2-http
dataweave
smartassembly
960.gs
webos
ffi
rethinkdb-python
angular-chart
friend-function
jsdoc3
docker-registry
xml-rpc
collaborative-filtering
jquery-tags-input
munin
stdio
jwrapper
z-order
spock-reports
webtorrent
client-side
anthill
little-endian
mediafire
splash-screen
bitcount
rebase
jedit
gridsplitter
bitarray
django-pipeline
du
custom-validators
event-loop
t4-toolbox
ncbi
voog
google-text-to-speech
componentone
desktop-shortcut
kindle-fire
apache-tomee
kooboo
cxf-client
sandbox-solution
microsoft-commerce-server
styledtext
mapstraction
yepnope
where-in
dbase
jbossws
asp.net-compiler
kendo-tooltip
firepad
mdbtools
aspnet-regiis.exe
mathtype
jquery-textext
iwebkit
pmp
ios5.1
converters
ejbql
jlayer
nexus-7
wind-river-workbench
juggernaut
set-include-path
entityreference
windows-2000
xla

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile