Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cpp_demo #154
base: master
Are you sure you want to change the base?
Add cpp_demo #154
Changes from 2 commits
a6c375f
f8c825b
cb93099
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you want to
=delete
this here? when would you want to declareMatrix M;
on its own (and what dimensions would it have?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question, in practice having containers or other data structures using matrix comes up. If these data structures are default constructed, it will invoke default constructor on matrix. A lot of times, you can't initialize the matrices at the time of construction of the container. As an example, think about a graph implementation using adjacency matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are other ways of achieving the similar thing like putting default values for nrows = 0 and ncols = 0 instead, but I just chose this cuz it highlights usage of =default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo that's kinda beyond the scope of these notes – will defer to judgement of other reviewers. @lucieleblanc @themost1 @al3623 what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this deeper reason for why I included it is way beyond the scope of class and actually totally subjective. For the students, I just want to say: I want a default constructor cuz I want it and here's a nice and simple way to let compiler generate it for you even if you defined your own constructor. The important thing is that you know how to do it.
Same thing with my decision to implement matrix with 1-dimensional array rather than like std::vector<std::vector>. I did that cuz it usually takes advantage of cache better, but all they need to know is I need something to hold the data and here's how you allocate/deallocate in ctor/dtor.