code_junkie

Variable sized class - C++

Nov 13th, 2011
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. class StringChild : public StringBase
  2. {
  3. public:
  4. //some non-virtual functions
  5. static StringChild* CreateMe(int size);
  6. private:
  7. unsigned char iBuf[1];
  8. };
  9.  
  10. return new(malloc(__builtin_offsetof(StringChild ,iBuf[size]))) StringChild();
  11.  
  12. return new(malloc(__builtin_offsetof(StringChild ,iBuf[size]))) StringChild();
  13.  
  14. obj->~StringChild();
  15. free(obj);
Add Comment
Please, Sign In to add comment