When you create the array it will automatically create all Student objects in it using the default constructor, so no need to do things like list[0] = Student();.
Do you understand what list[0] = Student(); is doing? First a temporary object of type Student is created using the default constructor. The temporary object is then assigned to the already existing object list[0]. This means that list[0].id will be set to the id of the temporary object. And then, before the statement ends, the temporary object is destroyed. What happens is similar to this:
1 2 3 4
{
Student tmp;
list[0] = tmp;
}
So, can't you just avoid doing this?
If that is not an option, well maybe you should move the id generation to a function instead so that you can do: list[0].giveUniqueId();