How to apply sizeof() operator to non-static class member methods?
问题 struct MyClass { int foo () { return 0; } }; unsigned int size = sizeof(MyClass::foo); // obviously error Can we apply sizeof() to member methods from outside the class ? Do we need to declare object to get it ? Edit : I know that above code will give error (that's why word 'obviously'). Wanted to know if we can at all apply the sizeof() to a member method. I don't want to describe the use case for that in length. 回答1: You cannot obtain the size of a member-function , but you can obtain the