+ 1
Doubt in pointer
I have recently learnt concepts of pointers in C++ and I have found, in few programs, to assign a pointer to the address of a variable, sometimes they use the line of code - int *p = &num ; and sometimes they use - int p = &num ; So are these lines of codes equivalent and the placing of asterics sign is insignificant? Please help me have a clear idea.
3 Answers
+ 8
You cannot do
int p = #
The address of num can only be stored in a pointer. I suppose you mean:
int& p = num; ?
+ 1
https://code.sololearn.com/cFK8o7i1XKyh/?ref=app
Check this out. I think its clear enough.