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

multiplication of two integer arrays
get and set Enum variable inside a class?
How to use make “using” keyword within a method to accept it as class level
std::array-like class copy constructor
Access violation when using delete
C++ SFML compile error + install
Resizing 2D vector C++, Setting to 0
Finding the shortest word ladder between two given words and a dictionary
Is this function doing something wrong with the sockets?
How to use the same multidimensional array in many functions?
C++ namespace: using without owning
How can I change the border style of a Tab Control?
gtest installed with conan: undefined reference to `testing::internal::GetBoolAssertionFailureMessage`
how much memory would it take to store a reference to an object in C++?
Per vertex weighted normal keeping in mind the crease angle in OpenGL C++
std::vector< T >::iterator with accessible constructor

Categories

HOME
machine-learning
git
gradle
perl
dropbox-api
screensaver
accounting
kotlin
basecamp
apache-apex
distributed-database
bigdata
fontforge
mupdf
filenet-p8
spring-data-elasticsearch
zillow
mitmproxy
nattable
packet-capture
touch
revit
django-channels
filepicker.io
frama-c
endpoints-proto-datastore
protobuf-c
induction
kinvey
word
lsmeans
submenu
angular-daterangepicker
dexguard
gunicorn
powerdesigner
nsubstitute
digestive-functors
fpu
actor
jenkinsfile
reddit
auto-value
reduce
xc8
react-d3
friend-function
wso2-appm
dependency-properties
fuzzy
angularjs-service
powerview
simplehttpserver
erwin
synopsys-vcs
powershell-tools
unite.vim
visual-c++-2013
hashset
code-collaborator
twebbrowser
devpartner
datepart
antivirus-integration
rc4-cipher
phpinfo
anonymity
android-6.0.1
idiorm
rebase
divider
javascript-globalize
pysqlite
gridsplitter
tstringgrid
eofexception
cpanm
proto
pixman
soundex
irssi
comfortable-mexican-sofa
ember-qunit
orca
xcode6.1
apache-commons-exec
httpwatch
django-1.2
spn
problem-steps-recorder
inner-classes
scite
jbossws
mathtype
dynamic-languages
customvalidator
nservicebus3
dvorak
system-design
launching-application
mobile-phones
mono-service
cohesion
flotr
bootclasspath
test-environments
widechar
id-generation
codehighlighter
olpc
trackback
pointer-arithmetic
pdc2008
pia

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