Thread: Link List assignment

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Angry Link List assignment

    I'm having problems linking my list with this c++ program can someone help please. I have the file of what i've done so far. I need help bad

  2. #2
    Registered User Fractur0x65's Avatar
    Join Date
    Nov 2010
    Location
    Eastern U.S.
    Posts
    10
    You'll need to actually post whatever code you've written so far (remember to put any code inside the [CODE] [/CODE] tags) if you want someone to help you. We can't see what your doing wrong if we can't see exactly what you did in the first place.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    5
    Code:
    //linklist.cpp
    
    class Student
    {
    public:
    // Variables
    	int StudentID;
    	string Name;
    	string Address;
    	int Units;
    	double GPA;
    
    // Constructors:
    	Student();	// <== Same name, No Return type
    	Student(string Name);
    	Student(string Name, string Address,
    		   int Units, double GPA=0.00);
    
    // Other Functions:
    	void Party();
    
    // Destructor:
    	~Student();	// <== Tilde ~Same name, No Return type
    
    };				// <== Don’t forget the semi-colon!!!
    
    // First Constructor (stub):
    Student::Student()
    {
    		cout << "I am created!\n";
    }
    // Function (stub):
    void Student::Party()
    {
    		cout << "Yipee!\n";
    }
    
    // Destructor (stub):
    Student::~Student()
    {
    		cout << "I am destructed!\n";
    }

    //client.cpp

    Code:
    #include "Linklist.h
    
    int main ()
    {
    	LinkList list;
    	list.Print();
    	list.RemoveFirst();
    	list.Print();
    	list.Search(67);
    	list.Print();
    	return 0;
    }

    // linklist.h (missing) i need help!!!!!!!


    here's the link for the actual assignment
    http://www.mediafire.com/?7yah4696cvp7cny
    Last edited by deemusic836; 11-27-2010 at 11:48 AM. Reason: add on

  4. #4
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154
    What is the following line of code missing?
    Code:
    #include "Linklist.h


  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Angry

    implementing this part is frustrating me

    LinkList list;
    list.Print();
    list.RemoveFirst();
    list.Print();
    list.Search(67);
    list.Print();

  6. #6
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154
    Perhaps I am missing something really trivial, and if that is the case, feel free to point it out to me, but in the code you have posted you say:

    "implementing this part is frustrating me

    LinkList list;
    ..."

    Yet in all the other code you have posted (namely 'LinkList.cpp'), you make no reference to your type 'LinkList', instead you have all these references to a class called 'Student'. How is 'Student' related to 'LinkList' (I presume 'LinkList' is a class, but I am yet to see that in code). Not to mention, you are giving no information about exactly why implementing the code listed is frustrating you - What exactly is the problem? What compilation errors do you get - if any?

    The better and more precise the questions you ask, the better and more precise will be your answers. You are attempting to get answers to your questions without giving anyone on here adequate information - no wonder you haven't had any particularly useful responses in this thread so far.


  7. #7
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    463
    Maybe you should use a struct:
    Code:
    struct Student
    {
    	int StudentID;
    	string Name;
    	string Address;
    	int Units;
    	double GPA;
            Student * prev; // link to the student before
            Student * next; // link to the student after
    }
    
    class CLASSROM // for example
    {
    private: 
         Student * head; // this is the head of the list
    public:
    
    ...
    }
    This is an example of a linked list. what you wrote was not a linked list. Notice "Student * prev" and "Student * next", those are the links to the previous struct student and next struct student.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  2. reading data from a file - link list
    By peter_hii in forum C++ Programming
    Replies: 7
    Last Post: 10-25-2006, 09:11 AM
  3. compiler build error
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2003, 10:16 AM
  4. 1st Class LIST ADT
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-09-2001, 07:29 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM