Jump to content
Sign in to follow this  
matko95

Salah Declare Rasenyer

Recommended Posts

#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??

Share this post


Link to post
Share on other sites

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.. :lol:

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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...

:lol:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...