且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有函数的类的c ++ sizeof()

更新时间:2022-05-19 23:28:51

该类不包含数据成员,因此为空.标准要求每个班级至少有大小 1,所以这就是你得到的.(成员函数实际上并不在类内部",它们实际上只是具有隐藏参数、命名空间和访问控制的***函数.)

The class contains no data members, so it's empty. The standard demands that every class have at least size 1, so that's what you get. (Member functions aren't physically "inside" a class, they're really just free functions with a hidden argument and a namespace and access control.)