Difference between Reference and Pointer and a pointer

Asked 2 years ago, Updated 2 years ago, 89 views

I know that using references makes it easier to read and write code, What exactly is the difference between the two?

c c++ reference pointer

2022-09-22 22:25

1 Answers

For example,

void getPtr(int* ptr){
    getPtr(ptr+5); //ok
}

void getRef(int& ref){
    getRef(ref+5); //not ok
}

This is.

When implementing algorithms or data structures, we usually use pointers Other than that, I usually use references


2022-09-22 22:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.