现在在Win8中经常看到Lambda表达式:
例如:
outputText = "The FAL list contains the following item(s):\n\n";
std::for_each(begin(entries), end(entries), [this, &outputText](const AccessListEntry& entry)
{
outputText += entry.Metadata + "\n"; // Application previously chose to store sampleFile->Name in this field
});
create_task(FileIO::ReadTextAsync(file)).then([this, file](String^ fileContent)
{
OutputTextBlock->Text = "The file '" + file->Name + "' was opened by a stored token from the MRU list, it contains the following text:\n\n" + fileContent;
});
问题1:请问为什么都需要this关键字呢?
问题2:有时使用&符号,有时却不使用:是否这个是否是需要传递引用时候使用&符号,当对象本身已经是引用类型就不需要了呢?可是代码中的outputtext是字符串引用类型为什么还是需要&符号呢,file却不使用&符号?请求解惑