|
-
February 20th, 2012, 03:50 PM
#1
Help please.. C++ college work
some1 please run this header file for me and fix it please, im not an avid programmer and my visual C++ is giving problems, the work is due this week please some1 HELP!!!
**** its on link lists*****
//headerfile
# include <cstdlib>
# include <string>
class node{
char name;
char course;
int id_num;
node *nextnode;
public:
node();
node(char, char, int);
~node();
char getname();
void setname();
char getcourse();
void setcourse();
int getid();
void setid();
void insertbegining ();
void insertend();
void insertposition();
void transverse();
void deletefirst();
void deletelast();
void deleteposition();
void exit();
};
node::node()
:name(0), course(0), id_num(0), nextnode(NULL)
{
};
node::node(char n, char c, int id){
name = n;
course = c;
id_num = id;
};
node::~node(){
delete nextnode;
};
char node::setname(char){
name = n;
};
void node::getname(void){
return name;
};
char node::setcourse(char){
course = c;
};
void node::getncourse(void){
return course;
};
int node::setid_num(int){
id_num = id;
};
void node::getid_num(void){
id_num = id;
};
void node: isplay(){
conducter = ptr;
if ( conducter != 0 ) {
while ( conducter->nextnode != 0 ) {
cout<< conducter->name << conducter->course << conduter->id_num<<endl;
conducter = conducter->nextnode;
}
cout<< conducter->name << conducter->course << conducter->id_num<<endl;
}
};
void node::insertbeginning(){
node *ptr;
node *conducter;
ptr= new node;
ptr-> nextnode = 0;
cout<<"enter the name of the student"<<endl;
ptr->name=n;
cout<<"enter the course of the student"<<endl;
ptr->course=c;
cout<<"enter the ID number of the student"<<endl;
ptr->id_num=id;
conducter=ptr;
if ( conductor != 0 ) {
while ( conductor->nextnode != 0)
conductor = conductor->nextnode;
}
};
void node::insertend(){
node *ptr;
node *conducter;
while(ptr->nextnode!=0){ // go to the last node
ptr = ptr->nextnode;
}
ptr= new node;
ptr-> nextnode = 0;
cout<<"enter the name of the student"<<endl;
ptr->name=n;
cout<<"enter the course of the student"<<endl;
ptr->course=c;
cout<<"enter the ID number of the student"<<endl;
ptr->id_num=id;
if ( conductor != 0 ) {
while ( conductor->nextnode != 0)
conductor = conductor->nextnode;
}
};
void node::insertposition(){
cout<<"Enter the node number"<<endl;
cin<<node_number;
node *ptr;
ptr=head;
for ( int i = 1 ; i < node_number ; i++ ){
ptr->ptr=nextnode;
if( ptr == NULL )
{
cout<<node_number<<" node is not exist"<< endl;
break;
}
}
ptr= new node;
ptr-> nextnode = 0;
cout<<"enter the name of the student"<<endl;
ptr->name=n;
cout<<"enter the course of the student"<<endl;
ptr->course=c;
cout<<"enter the ID number of the student"<<endl;
ptr->id_num=id;
};
void node: eletefirst(){
node *ptr;;
ptr=head;
ptr-> nextnode = 0;
delete (nextnode);
};
void node: eletelast(){
node *ptr;
while(ptr->nextnode!=0){ // go to the last node
ptr = ptr->nextnode;
}
delete(nextnode);
};
void node: eleteposition(){
cout<<"Enter the node number"<<endl;
cin<<node_number;
node *ptr;
ptr=head;
for ( int i = 1 ; i < node_number ; i++ ){
ptr->ptr=nextnode;
if( ptr == NULL )
{
cout<<node_number<<" node is not exist"<< endl;
break;
}
}
delete(nextnode);
};
void node::exit(){
system("CLS");
};
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|