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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -