CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Exclamation 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");
    };

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Help please.. C++ college work

    Quote Originally Posted by Norek View Post
    some1 please run this header file for me and fix it please, im not an avid programmer and my visual C++ is giving problems,
    What problems do you have: compiling, linking, executing?
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2011
    Posts
    97

    Re: Help please.. C++ college work

    We're not a homework help forum. If you have a particular issue, you can ask about it, but don't expect us to do your homework for you. In fact, if I recall correctly, I think it might even be against forum rules (which you should definitely read).

    Also, please use code tags next time. Even if we wanted to help, your code is impossible to read on this forum.

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Help please.. C++ college work

    First use code tags when posting code to preserve indentation.

    Second, a char only holds one character. You either want a char array or a string.

    Third, tackle the errors one at a time. The first error I see is this function.
    Code:
    char node::setname(char){
    name = n;
    };
    You declared the function to take no arguments, but you implemented it with one argument. They need to be consistent.

  5. #5
    Join Date
    Feb 2012
    Posts
    10

    Re: Help please.. C++ college work

    I agree there are so many inconsistency in your code

    Code:
    char getname();
    void setname();
    char getcourse();
    void setcourse();
    int getid();
    void setid();
    
    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;
    };
    for example:

    - setname and setcourse doesn't have a parameter in your declaration but you define it with parameter.

    - setname and setcourse function has a return value but you define it without a return value

    - you define function but forgot to declare it. setid_num, getid_num and getncourse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured