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

Array of fstream in C++
Error: (E107) bind interface to port failed: interface already bound to port: port 'MC8051_ALU().AM.port_27' (sc_in)
Error LINK2019 when I try to make a training for face detection [duplicate]
Quickest way to iterate in a C++ vector
How can I use snmp++ to enable/disable a switch port?
i wan't to use char* in this code instead of string how? [closed]
Using inRange() in OpenCV to detect colors in a range
The string.h 's function does not work in C++ but string does [on hold]
How to efficiently insert/merge into thrust::device_vector?
Change to transparent rectangle
Why addDays not working? [on hold]
OpenGL or GLFW renders ok only when moving the window
How to make static callback c++
How to copy host vector to device vector by thrust
conversion of string to const char*
Overloading structs with template call operator and generic lambdas - gcc vs clang

Categories

HOME
git
parsing
momentjs
drawing
cron
selenium-webdriver
asp-classic
text
scenekit
metal
bootstrap-datepicker
binary
virtocommerce
inform7
iis-8
apache-spark-2.0
c#-3.0
gemfire
pivot-table
windows-authentication
apigee
wmi-query
esapi
cognos-10
pyside
polymer-1.0
cider
xfce
vowpalwabbit
jointjs
kinvey
asp.net-mvc-routing
sequences
umbraco-mvc
tridion
transitions
youtube-analytics
angular2-http
android-auto
reduce
autocorrect
winlims
virsh
webpack-style-loader
schemaless
vqmod
libtool
c#-to-vb.net
use-case
cpio
stdio
helium
suppress-warnings
windows-firewall-api
report-viewer2012
jwrapper
news-feed
review-board
post-commit
dart-polymer
mailman
client-side
kmip
android-selector
rodbc
spawn-fcgi
listboxitem
stage3d
divider
distinct-on
xcode-bots
wordpress-4.5
dynamic-ip
tap
treenode
jxa
ttml
grunt-contrib-cssmin
kismet-wireless
zend-http-client
mooc
wtl
workbench
pegjs
subsonic2.2
code-metrics
worklight-server
runscope
ios-provisioning
jform-designer
invalidation
psychology
facebook-app-center
google-email-settings-api
boost-spirit-karma
texinfo
google-doodle
libjson
pointer-arithmetic
isaserver
pdc2008
o3d

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile