Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第三节课、ppt第54页,用 [=] 来捕获传参的lambda表达式为什么占4个字节? #11

Closed
qd1308504206 opened this issue Jul 15, 2022 · 3 comments

Comments

@qd1308504206
Copy link

qd1308504206 commented Jul 15, 2022

image

按照我的理解是:
1:函数指针8个字节
2:带int变量fac,4个字节。应该是12个字节才对。

但是这个地方理解不清楚,还请彭哥帮忙解答一下

@z-learner
Copy link

z-learner commented Jul 15, 2022

这里应该并不涉及函数指针的问题,lambda表达式返回的是应该可以理解为一个重载了()操作符的匿名对象,这个对象中有一个n成员变量(值传递),所以这个对象占4个字节。
就好比自己随便创建一个类,这个类的大小只取决于类中所包含的成员变量,而与类的成员函数无关。

@archibate
Copy link
Collaborator

archibate commented Jul 17, 2022 via email

@qd1308504206
Copy link
Author

懂了。thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants