This is not a typical way of iterating through a linked list:
while (m->next != 0) {
cout << m->d << endl;
m = m->next;
}
Instead, you should do:
while (m != 0) {
cout << m->d << endl;
m = m->next;
}
If you do this, you'll see that the linked list you initially created is actually:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
Your Printing logic then prints it as:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Your reverse then likely functions correctly, producing a list of:
0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
Which you print as:
0, 9, 8, 7, 6, 5, 4, 3, 2, 1