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

Turn conditional recursion algorithm to an iterative one
How to properly define stream operators for templates in C++
How can I build multiple products with different dependency versions in Visual Studio?
remove stop words from a text file
C++ weak_ptr creation performance
bad memory allocation while doing opencv2 bruteforce matcher
Is it possible to obtain a QModelIndex from col and row [closed]
What actually happens in C++ when I call “delete?” [closed]
Making program to close automatically after clicking on NO on a MessageBox (C++)
opengl32.lib wont link to project
Condition checking: if(x==0) vs. if(!x)
How to show list of strings in QT at run time?
Passing struct to function in C++ [closed]
Why is this swap function call ambiguous? [duplicate]
C++ Storing rows as part of a 2D array and then printing a row [closed]
Segfault: Track down “invalid read” “free'd at”

Categories

HOME
docker
ruby-on-rails-4
firmware
data-warehouse
function
accounting
soap
statistics
windows-installer
chart.js
outlook-addin
pstricks
http-headers
tensorboard
spf
jasperserver
apostrophe-cms
shoutem
axon
kafka-consumer-api
licode
netbeans-7.3
ajaxform
robots.txt
stackdriver
jquery-animate
fgets
unimrcp
ssis-2008
mikrotik
entity-relationship
rubinius
pywavelets
git-clone
dsolve
master-detail
hipchat
jquery-ui-autocomplete
choropleth
c#-to-f#
neoscms
appery.io
sharethis
crawler4j
package-name
tablet
product-key
database-theory
google-tv
audiokit
google-nearby
oracle-sql-data-modeler
fixture
uievent
jenkinsfile
interstitial
simplemodal
evosuite
wistia
virsh
strconv
sift
release-management
dispy
mongodb-scala
cscope
google-gadget
simplehttpserver
siteminder
onbeforeunload
nsthread
dotpeek
servant
spawn-fcgi
anonymity
ng-template
android-6.0.1
bitcount
cirqus
jlist
msbuildcommunitytasks
euclidean-distance
order-of-operations
wave
soundex
event-loop
t4-toolbox
treenode
orchardcms-1.6
stacked-area-chart
tankauth
xcode6.1
zurb-joyride
linq-to-lucene
countries
mindmap
facebook-events
batoo
jpreloader
cgimagesource
circusd
struts-config
sts-securitytokenservice
glossary
mobile-phones
iphone-sdk-3.0
windows-live-writer
trx
nsenumerator
multiple-versions
maintenance-plan
testing-strategies

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App