Help with my linked list please!

Ok, so I have to make a linked list for my school assignment and i can't use the std lib to make it. Im having trouble making it although I understand the concept.
there are two components to my node class(value and next pointer). Currently I am working on the function to add a new node to the beginning of the List. I need many more functions but am so stuck I can use any help i can get. THANKS!

As u can see, my insertfront function is an absolute mess, but I can't really figure out what to do...

MAIN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <stddef.h>
#include <Staque.cpp>
using namespace std;



int main()
{
    int entry;
    cout<<"welcome to my program"<<endl;
    cout<<"please enter a number to enter to my list!"<<endl;
    cin>>entry;
    Staque.InsertFront(entry);
    Staque.Display();

    return 1;
}


Staque.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Staque.h"
#include <stddef.h>
#include "Staque.h"

using namespace std;

Staque::Staque()
{
}

void Staque::InsertFront(int value)
{
    Staque.node *root;
    root->Staque.Node.numb=value;
    root->link=NULL;
}

void Staque::Display()
{
    cout<<Staque();
}


Staque.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef STAQUE_H
#define STAQUE_H


class Staque
{
    public:
        Staque();
        void InsertFront(int);
        void InsertBack(int);
        void Display();
        void popFront();
        void popBack();
    private:
        class node
        {
        int numb;
        node * link;
        }*p;
};

#endif // STAQUE_H
Last edited on
First things first.

Little bit confused as to what you want here. Your title suggests a linked list, your class name is stack and your functions look like that of a deque.

Which is it precisely? Are you sure you understand the concept of a linked list? Because this post suggests that you're mixing the general principles of the three structures mentioned.
Last edited on
Topic archived. No new replies allowed.