Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这可能是一个非常愚蠢的问题,但这究竟是什么名字?看过 function()-> 很多次,一直不知道叫什么。另外我怎样才能创建自己的?
function()->
GetDocument()->SetModifiedFlag(1);
这个结构没有名字,因为它没有什么特别之处。
它只是->应用于由 . 返回的值的运算符function()。
->
function()
如果用于函数定义,则称为返回类型声明。
auto myfunctiona() -> int { return 0; }
如果在表达式中使用它,则箭头运算符会取消引用访问成员的指针。在您的示例中,该函数GetDocument()需要返回一个指向对象的指针。该对象的类型必须有一个成员函数SetModifiedFlag()。
GetDocument()
SetModifiedFlag()