Exercise: Default Constructor (was: Arrays of Objects)¶
Description¶
Download and (try to) compile the following code:
#include "user.h"
int main()
{
User users[10]; // does that work?
return 0;
}
Does it work? (No)
C++, when arrays of objects (i.e. instances of classes) are created, the array members must be initialized ⟶ their constructors are called.
Solution: add a default constructor to class User