We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, I had a question..
Why is it that when you use 'const Box&B' as a parameter in your operator overloading function, you can directly access the private variables of B? I saw that if I don't write 'const', I can't access the private variables and thus need to access them through the getLength, get Breadth and getHeight functions. Can you please explain the difference and significance of the const keyword here?
Thank You.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Box It!
You are viewing a single comment's thread. Return to all comments →
Hi, I had a question.. Why is it that when you use 'const Box&B' as a parameter in your operator overloading function, you can directly access the private variables of B? I saw that if I don't write 'const', I can't access the private variables and thus need to access them through the getLength, get Breadth and getHeight functions. Can you please explain the difference and significance of the const keyword here?
Thank You.