中国开发网: 论坛: 程序员情感CBD: 贴子 420218
mhappy
一小段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);
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录