c++ - Is there any overhead to define complicated (large size) class inside another class? -


to make question clear, i'll give simplified example:

class foo { public:     class bar {         int garbage[1000000];     };     void playwithgarbage() {          //whatever...     }  } 

now, if generate lot of instances of foo , pass them around value or reference. there significant overhead? tested size, , it's ok: sizeof(foo) returns 1

there no overhead objects of type foo. foo acts namespace in bar contained. existence of foo::bar objects independent of existence of foo objects. if foo had bar member, however, objects of type foo have subobjects of type bar , therefore have increased size.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -