matko95 0 Report post Posted March 15, 2008 #include <iostream.h>#include <process.h>class doubly{ doubly * next; doubly * pre; int ch; char name;public: doubly * link(doubly * ); void traverse (doubly * );};doubly * doubly::link(doubly * temp){ doubly * newlink; doubly * cur; newlink = new doubly; cout<<"\nEnter First alphabet (only 1):"; cin>>name; cur = temp; if(temp == NULL) { newlink->name = name; newlink->pre = NULL; newlink->next = NULL; temp = newlink; return temp; } else { while(cur->next != NULL) { cur = cur->next ; } newlink->name = name; newlink->pre = cur; newlink->next = NULL; cur->next = newlink; return temp; }}void doubly::traverse(doubly *temp){ int ch; doubly * dummy; dummy = temp; cout<<"\n[1] Start From Begainning\n[2] Start From End\n"; cout<<"\nEnter Your Choice :"; cin>>ch; switch(ch) { case 1: if(dummy != NULL) { while(temp->next !=NULL) { cout<<temp->name<<endl; temp=temp->next; } if (temp->next == NULL) cout<<temp->name<<endl; } break; case 2: if(temp != NULL) { temp = dummy; while(dummy->next !=NULL) { dummy=dummy->next; } while(dummy->pre !=NULL) { cout<<dummy->name<<endl; dummy=dummy->pre; } if (dummy->pre == NULL) cout<<dummy->name<<endl; } break; }}void main(){ doubly *first=NULL,d1; int choice;while(1) { cout<<"\n************** WELCOME TO MMC CORPORATION **************\n\n"; cout<<"Choices Are :-\n=>[1] For Insert \n=>[2] For Traverse \n=>[3] For Exit"; cout<<"\n\nEnter Your choice : "; cin>>choice; switch (choice) { case 1: first=d1.link(first); break; case 2: d1.traverse(first); break; case 3: exit(0); } }}akum putera expert and sifu....ni nak mintak tolong skit....saya nak masukkan data tntg staff dan nak declare char tp...sy buat bleh masukkan value jer....sesapa bleh tlg?? Quote Share this post Link to post Share on other sites
zeph 1 Report post Posted March 17, 2008 awak tertinggal line ini:-using namespace std; Quote Share this post Link to post Share on other sites
atye 0 Report post Posted March 23, 2008 awak tertinggal line ini:-using namespace std;em..kalau dah gune <iostream.h> kne letak lg ke using namespace std; ni?sbb yg aku bace2 lm intenet la..diorg kate <iostream.h> ni coding versi lame..btol ke?aku pon xtau sgt..juz nk tmbh ilmu je..kalau salah tolong betulkan.. Quote Share this post Link to post Share on other sites
zeph 1 Report post Posted March 24, 2008 yer, latest c++ standard dah buang .h dari iostream tu. btw, kena faham jugak apa fungsi namespace tu. kalau taknak letak 'using namespace', maka function standard macam cin, cout, etc mest guna std::cout instead just cout. Quote Share this post Link to post Share on other sites
atye 0 Report post Posted March 24, 2008 yer, latest c++ standard dah buang .h dari iostream tu. btw, kena faham jugak apa fungsi namespace tu. kalau taknak letak 'using namespace', maka function standard macam cin, cout, etc mest guna std::cout instead just cout.owh..cmtu... Quote Share this post Link to post Share on other sites