The basic steps in finding the connected components are,
1. Search for the next unlabeled pixel of value 'A'
2. Use a flood-fill algorithm to label all the pixels in the connected component containing 'A'.
3. Repeat steps 1 and 2 until all the pixels are labelled.
Going through MATLAB documentation might help you.
Regarding your question for white/black pixel:
I can say it, But, it would be good if you test it yourself by passing a binary image and the inverted binary image to the function. So that you can experience it yourself.
Step 2 is ambiguous, I think that flood-fill algorithm use to label all the pixels in entire image to become labeled, if this pixel is labeled, this means it belongs to one of the connected components. Is it not?