Yes and no...
In your particular case, no. A structure is nothing more than a data container, and a function is located elsewhere. When the function is called, the pointer to the structure is passed as an additional, implicit first parameter, which is displayed as the this pointer inside the function.
Matter changes, however, if you add a virtual function. Although the C ++ standard does not provide for it, vtables are the defacto standard, and the class will receive a pointer to vtable as the first but invisible member. You can try this by printing the size of the object before and after adding the virtual function.
On the other hand, if the class is virtual due to inheritance from another class that already has virtual functions, the memory layout will no longer be changed, since there is already a pointer to the included table vtable (although it will point to a different location for instances of the subclass) .
source share