In the for loop below:
struct Block
{
Block(int d) : data(d), next(nullptr) {}
int data;
Block* next;
};
Block* aList = new Block(1);
Block* bList = new Block(2);
for (Block* a = aList, *b = bList; a != nullptr; a = a->next, b = b->next)
if (aList->data != bList->data)
cout << "Difference found.\n";
I don't like putting the * before b, but of course it's needed to distinguish Block from Block*. Is there another way to do this? for ((Block*) a, b...
isn't a go.