struct wheel_node
{
int contents;
wheel_node* next;
};
typedef wheel_node* wheel_ptr;
class wheel
{
private:
wheel_ptr arrow;
public:
wheel ();
void print ();
void spin (int distance);
void move_to (int number);
};
The constructor wheel creates a circular linked list as follows:
arrow -> 5 -> 40 -> 75 -> 10 -> 45 -> 80-> 15 … 70
That is, the first element is 5 and 35 is repeatedly added to obtain the next element (with wrap-around at 100).
What should my constructor wheel (); function definition be for it to do the above:
This is what i've tried to to:
wheel::wheel ()
{
wheel_ptr mover;
arrow = new wheel_node;
arrow -> contents = 5;
for ( mover = arrows -> cotents ; mover <100; mover = mover -> next)
{
arrow -> next = mover + 35;
}
if ( arrow -> next > 100 )
arrow -> next = mover - 100;
}