can someone please help me with making this class
- From: sparks <jobob@xxxxxxxx>
- Date: Sat, 25 Mar 2006 18:37:28 GMT
I wrote a program for linked list(I have included the insert routine)
this works fine.
======================================================
struct node
{
string Drname;
string phoneNo;
node *nxt;
};
node *start_ptr = NULL;
node *current;
int option = 0;
//sorted insert in list
void insert_node(string name, string phone)
{
node *temp, *prev ;
temp = new node;
prev = new node;
temp->Drname = name;
temp->phoneNo = phone;
temp->nxt = NULL;
prev->nxt = NULL;
if (start_ptr == NULL)
{
start_ptr = temp;
current = start_ptr;
}
else
{
temp=start_ptr;
prev=NULL;
if (temp->phoneNo < start_ptr->phoneNo)
{
temp->nxt = start_ptr;
start_ptr->nxt = NULL;
}
else
{
while((temp->nxt != NULL) && (temp->phoneNo < current->phoneNo))
{
prev->nxt = temp;
temp = temp -> nxt;
}
temp->nxt = current;
prev->nxt = temp;
}
}
cout<<current->Drname<<endl;
}
======================================================
PROBLEM is when I try to make a class for this
I have a mess and not sure why
class node
{
public:
string Drname;
string phoneNo;
node *nxt;
node()
{
Drname=NULL;
phoneNo=NULL;
nxt=NULL;
}
~node()
};
When I try to compile it says string Drname is not defined same with phoneNo
yep I am a noob and just learning but I can't understand if its syntax or stupid code.
thanks big time for any help
this is driving me crazy.
Jerry
.
- Follow-Ups:
- Re: can someone please help me with making this class
- From: Barry Schwarz
- Re: can someone please help me with making this class
- Prev by Date: Re: ERROR_DLL_INIT_FAILED - HELP please
- Next by Date: Re: Function call evaluation order
- Previous by thread: Unique 32-bit ID
- Next by thread: Re: can someone please help me with making this class
- Index(es):
Loading