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