Linked list and classes question

Hello!. I followed a guide on youtube and made a linked list, but i don't really know how to make it more "c++ish", with classes and such.

http://hastebin.com/uwokuzusij.cpp

I don't want to do anything fancy, i just want to get better at how classes work and learn how i can use them in different situations.

All help is much appreciated.

Best regards.
Janbananberg
No one can help me? "/
.
Last edited on
The function where you pass the head as the first parameter can easily turned into a class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class list
{
private:
  node *head;
  node *last;

public:
  list() : head{}, last{}
  {
  }

  bool isEmpty();
  void insertAsFirstElement(int number);
  void insert(int number);
  void remove(); // clear() would be better. 
  void showList();
};
Thanks alot coder777! :) will try it!
Topic archived. No new replies allowed.