The online Cambridge dictionary gives this definition for comprise:
To have things or people as parts or members; to consist of:
- The course comprises a class book, a practice book, and a CD.
To be the parts or members of something; to make up something:
- Italian students comprise 60 percent of the class.
- The class is comprised mainly of Italian and French students.
- Visible light comprises only a minute fraction of the electromagnetic spectrum.
If you study those examples carefully, you will see that comprise always refers to the complete contents of a set. For example, if the course comprises "a class book, a practice book, and a CD", we know it does not also include a video set. The key word in the definition is "consist of", which covers all the elements in the set.
The examples given with the second definition appear to contradict this rule, but not when correctly understood. For example, if "Italian students comprise 60 percent of the class", we must think of this as two different groups. The large group is the class. The smaller group is "60 percent of the class." It is a subset of the large group, the class as a whole. Now in that sentence comprise refers to the subset, which is completely filled up by the Italian students. It doesn't apply to the whole class.
So no, your second example is not correct. Your class cannot comprise 12 out 100 students.
You could rewrite the example along these lines:
Of the 100 students in our class, 12 are comprised of 5 French and 7 Chinese students.
This would be correct because it now refers to the makeup of the 12 student subset. But it feels cumbersome, so it's probably not the way native English speakers would put it. They would be more likely to say:
Our class of 100 includes 5 French and 7 Chinese students.