I explain my reasoning:
The possible combinations of hats of A and B are:
1. B, B
2. B, W
3. W, B
4. W, W
A thought as follows:
For C, in situation 1 he will know everything, but confuse in 2,3,4.
For B, if he saw A has Black hat, and C does not know anything, B will know he wears...