I've always been using structs, and we have to move away from struct nodes. I'm not sure how to implement an insert function (inserting in the beginning) for my list using node classes. I could REALLY use help!
Here's what I have for my node class:
class node
{
public:
node(); //constructor
int get_data(); //return data of node
void set_data(int number); //set data for node data
void set_next(node *); //
node * &get_next(); //return next pointer
// private:
int data;
node * next;
};
and I implemented them in my .cpp file with:
node::node()
{
data = 0;
next = NULL;
}
int node::get_data()
{
return data;
}
void node::set_data(int number)
{
data = number;
}
void node::set_next(node * m_next)
{
next = m_next;
}