To loop over each character in a string named myString, one could use for(_______ : myString).
- auto& ch
- char& ch
- int i
- string str
Using auto& ch in a range-based for loop allows iterating over each character directly without copying. The auto keyword infers the type, making the code cleaner.
Loading...
Related Quiz
- When implementing a finite state machine (FSM) in C++, which control structure might be more advantageous?
- How does the return statement interact with constructors or destructors in C++?
- What is the purpose of the this pointer in C++?
- Imagine you are maintaining a C++ application where memory leaks are a constant issue. Which type of pointer would be the best to use to ensure that dynamically allocated objects are properly deallocated?
- In C++, an abstract class can have a mix of abstract as well as _______ methods.