get rid of the keyword auto

This commit is contained in:
Jidong Xiao
2024-02-09 16:16:34 -05:00
parent 989133ee1d
commit ba43fdc3dc
2 changed files with 16 additions and 9 deletions

View File

@@ -185,8 +185,10 @@ int main() {
// Print the original list
std::cout << "Original list:" << std::endl;
for (const auto& person : people) {
std::cout << person.name << " (" << person.age << ")" << std::endl;
std::list<Person>::iterator itr = people.begin();
while(itr != people.end()){
std::cout << (*itr).name << " (" << (*itr).age << ")" << std::endl;
++itr;
}
// Sort the list of Person objects using the custom comparison function
@@ -194,8 +196,10 @@ int main() {
// Print the sorted list
std::cout << "\nSorted list:" << std::endl;
for (const auto& person : people) {
std::cout << person.name << " (" << person.age << ")" << std::endl;
itr = people.begin();
while(itr != people.end()){
std::cout << (*itr).name << " (" << (*itr).age << ")" << std::endl;
++itr;
}
return 0;

View File

@@ -27,8 +27,10 @@ int main() {
// Print the original list
std::cout << "Original list:" << std::endl;
for (const auto& person : people) {
std::cout << person.name << " (" << person.age << ")" << std::endl;
std::list<Person>::iterator itr = people.begin();
while(itr != people.end()){
std::cout << (*itr).name << " (" << (*itr).age << ")" << std::endl;
++itr;
}
// Sort the list of Person objects using the custom comparison function
@@ -36,10 +38,11 @@ int main() {
// Print the sorted list
std::cout << "\nSorted list:" << std::endl;
for (const auto& person : people) {
std::cout << person.name << " (" << person.age << ")" << std::endl;
itr = people.begin();
while(itr != people.end()){
std::cout << (*itr).name << " (" << (*itr).age << ")" << std::endl;
++itr;
}
return 0;
}