I find these two examples conceptually identical - yet one is a composition and the other aggregation.
In the first example, the relationship 'class (has-a) students' is a compositon.
A class contains students. A student cannot exist without a class. There exists composition between class and students.
In the second example, the relationship 'department (has-a) professors' is an aggregation.
If the university closes, the departments will no longer exist, but the professors in those departments will continue to exist
In my opinion the first one is plain wrong. Notice that in the comment section of this SO question @TallPaul is questioning the first example as well. I think in practice it would delete all students enrolled in a class after each semester from the system. Moreover, the students would probably have to be created by the class on its initialisation, because composition in C++ is usually implemented as private attribute (not pointer). Am I right? Is there any way the first example makes sense?