+ 1

What is the use of constant objects?

18th Feb 2020, 6:34 AM
Shatanik Mahanty
Shatanik Mahanty - avatar
5 Réponses
+ 5
It is covered in the lesson, in case you forget ... https://www.sololearn.com/learn/CPlusPlus/1895/
18th Feb 2020, 6:45 AM
Ipang
+ 2
I think it is used when we need to have an object that is read only, being set as const object, the code will raise an exception when some code try to modify the said object's attribute. It makes it easier to add protection against unplanned/accidental attempt of modifying the said object's attribute. I could be wrong, but that's what I understood from the lesson's description.
18th Feb 2020, 7:05 AM
Ipang
+ 2
No problem buddy 👌
18th Feb 2020, 7:39 AM
Ipang
+ 1
Thats fine. But the use of const object is not given .... Like why it is practically used Ipang
18th Feb 2020, 6:54 AM
Shatanik Mahanty
Shatanik Mahanty - avatar
+ 1
Thanks for explaining Ipang
18th Feb 2020, 7:29 AM
Shatanik Mahanty
Shatanik Mahanty - avatar