Displaying
char ref[5] = {'R', 'e', 'f'};
// Range based for loop
for (const int &n : ref) {
std::cout << std::string(1, n);
}
// Traditional for loop
for (int i = 0; i < sizeof(ref); ++i) {
std::cout << ref[i];
}
Comments
char ref[5] = {'R', 'e', 'f'};
// Range based for loop
for (const int &n : ref) {
std::cout << std::string(1, n);
}
// Traditional for loop
for (int i = 0; i < sizeof(ref); ++i) {
std::cout << ref[i];
}