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.
If you will write just auto c the ranged for will only intialize c with copy of a string element in every iteration of for. So the loop will just keep changing c and discarding its value everytime. But with auto &c a reference is created. If x is reference of y then its like two names x and y that denote the same variable y. So now c becomes just another name for our string element.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
If you will write just
auto c
the ranged for will only intialize c with copy of a string element in every iteration of for. So the loop will just keep changing c and discarding its value everytime. But withauto &c
a reference is created. Ifx
is reference ofy
then its like two names x and y that denote the same variable y. So nowc
becomes just another name for our string element.