lesson wipes out all in main() from previous lessons it seems (hard to tell, I can just see a fragment of the entire IDE) than adds
const Rectangle rectangle;
This throws “const object must be initialized” when trying to compile anything.
Does Rectangle.h need to be modified as well? Don’t see this in the lesson. Hard to believe you can just drop this into Main. can someone please explain why Example code won’t compile for me.
I solved this by using this line instead of what is in the example code.
const Rectangle rectangle(10,20);
So, the const thing seems to not work with the default constructor. Can anyone advise what should be done in .h file so the default (no height no width argued) works?
const
identifier’s value cannot be changed. It is required for a value to exist before tagging it as constant. In your case, there is no rectangle
that needs to be constant.
This works and now you know why.
If unsure, then rewatch the videos. Some videos do have issues that can be corrected if you manage to learn the concept being used. Other issues have been mentioned on the forum already. If not, then you can ask them by clearly mentioning what you want to ask.