| | |
What does *&p do?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I'm learning linked lists , and in my manual i have the following example.
Now , i understand the program ,except the first paramater of insertion (element *&p).
What does exactly means?Isn't element *p enough?Why we need the extra ampersand "&"?
thanks
c Syntax (Toggle Plain Text)
#include <iostream> using std::cout; using std::cin; using std::endl; struct element { int info; element *address; }; void insertion(element *&p,int nr) { element *c; c=new element; c->info=nr; c->address=p; p=c; } void print(element *p) { while(p!=0) { cout<<p->info<<endl; p=p->address; } } int main() { int nr; struct element *p=NULL; cout<<"Number ="; cin>>nr; while(nr!=0) { insertion(p,nr); cout<<"Number ="; cin>>nr; } print(p); return 0; }
Now , i understand the program ,except the first paramater of insertion (element *&p).
What does exactly means?Isn't element *p enough?Why we need the extra ampersand "&"?
thanks
Last edited by Eko; Nov 30th, 2006 at 8:24 am.
![]() |
Similar Threads
- Web Design & Development Company Hiring (Web Development Job Offers)
- Probelm in JSP with (& and # symbols) (JSP)
- PDA & GPS for UAV (Cellphones, PDAs and Handheld Devices)
- Connected ATX and AT PSU (Technical) (Motherboards, CPUs and RAM)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
Other Threads in the C++ Forum
- Previous Thread: C++, difficulties in choosing STL 's containers
- Next Thread: I need help please
Views: 1059 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





