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

unique_ptr after call to c_str() doesn't point to valid value
C++ how to skip next 2 iterations of loop i.e. multiple continue
How to create objects when the count is not known in prior
Reading data through COM #C++ Windows
C++ map do plus plus without initialization
QMediaPlayer.play() doesn't work if I call a function with it
How are two strings compared?
How to quickly write large amounts of data into txt files
Can I check whether an address is in shared memory?
Poco C++ Libraries: “Not found: mysql”
boost:asio::read or boost:asio::async_read with timeout
sorting of vector of struct according the criteria and then display result
Qt 5.6 install issue
Game Engine: How to transpose Variables from structs: Coding practices
Visual C++ - Compile with BMI2
Iterator end() function not working with pointer arithmetic

Categories

HOME
qt5
dll
instagram
wildfly
monitoring
luigi
authorization
import
instagram-api
glusterfs
http-headers
outlook-redemption
apigee
ninja
corba
mupdf
business-objects
amazon-route53
kafka-consumer-api
sirikit
markup
laravel-blade
pyside
zillow
premailer
pfsense
phylogeny
formsets
edi
akka-stream
ebcdic
u2
maxlength
white
jqassistant
protobuf-c
reactive-streams
gmail-contextual-gadgets
aspose-cells
layer
yamldotnet
powerdesigner
enzyme
automated-deployment
binary-image
khan-academy
grunt-string-replace
http-status-code-415
cakephp-2.x
wistia
django-compressor
db-schema
implicit
shodan
mongodb-scala
sonarqube-4.5
qt4.8
gio
imshow
reportviewer2008
mechanize
video-recording
agile-project-management
ubuntu-15.10
datepart
spawn-fcgi
customdialog
jquery-widgets
shapely
jcarousel
spsite
payara
cirqus
realbasic
html5builder
bitarray
django-pipeline
du
elasticsearch-marvel
cakedc
kismet-wireless
rgs
cleartool
chap-links-library
kindle-fire
tankauth
data-sharing
runscope
basic-msi
controltemplate
string-conversion
freetextbox
facebook-app-center
dbase
mib
readelf
django-sessions
keymando
jlayer
nested-queries
xemacs
wymeditor
ubuntu-9.10
raw-ethernet
vtl
open-flash-chart

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile