mhappy ·
·
阅读: 515
一小段STL,为啥最后调用printit不用带参数呢?
PrintIt (string& StringToPrint) {
cout << StringToPrint << endl;
}
int main (void) {
list<string> FruitAndVegetables;
FruitAndVegetables.push_back("carrot");
FruitAndVegetables.push_back("pumpkin");
FruitAndVegetables.push_back("potato");
FruitAndVegetables.push_front("apple");
FruitAndVegetables.push_front("pineapple");
for_each (FruitAndVegetables.begin(), FruitAndVegetables.end(), PrintIt);
}