Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reorder constructor warning/error. (#97)
The constructor of the base class is always called before the constructor of the subclass. This is true even if we call it at the end of the constructor initializer list of the subclass. We want to initialize `Event`'s `attributes_` with pointers coming from the subclass upon construction. The subclasses contain different attributes, create `vector<Attribute*>` in their constructor and pass it to the `Event` constructor. Since we were passing pointers, the program was still correct even if pointers were initialized after being passed to the base constructor. The error says we must move the call to the `Event` constructor to the beginning of the initializer list. Despite being correct, initializing the variables after passing them to the `Event` might look confusing. This is why we defined a protected method, `InitAttributes()`, that takes the attribute pointers and builds the `vector<Attribute*>` in the base class.
- Loading branch information
1 parent
664c2df
commit 7787cba
Showing
3 changed files
with
27 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters