I am using OpenCV for a C++ application. I have a 8 bit binary image that has some objects. The objects are all colored 255, whereas everything in the background is colored
You need to cv::floodFill the contours returned by cv::findCountours. See this example for findContours, and this one for floodFill
Starting from version 3.0, OpenCV has connectedComponents function.