C ++ sizeof包装类 [英] C++ sizeof wrapper class
本文介绍了C ++ sizeof包装类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
sizeof(A)== sizeof(T)
? 编辑:
此外,如果T是复合类型,差异?
不,可能超过 sizeof(T)
由于填充。
Suppose I have a class A that does not inherit from anything, has no virtual methods, and has exactly one variable of type T. Does C++ guarantee sizeof(A) == sizeof(T)
?
EDIT:
Also if T were a composite type, would it make a difference?
解决方案
No, it might be more than sizeof(T)
due to padding.
这篇关于C ++ sizeof包装类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文