what are internal padding

This is a discussion on what are internal padding within the C++ Programming forums, part of the General Programming Boards category; in my code i have three classes class A { protected: int x; }; class B ublic A { protected ...

  1. #1
    Unregistered
    Guest

    what are internal padding

    in my code i have three classes
    class A
    {
    protected:
    int x;
    };
    class Bublic A
    {
    protected :
    int y;
    };

    class Cublic B
    {
    protected:
    int z;
    };

    in the constructors of each class i cout the sizeof(class)
    on console the size is 4 bytes of each class...but as soon i include a char member ...the size of the respective class increases by 4 bytes...though the sizeof(char) is 1 byte.
    In help i got it may be due to internal or trailing padding.What are this padding and whats their significance....pls explain me.

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    padding means adding extra bytes to make things seem in order. it cuts time at the expense of space.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Internal Compiler Error
    By Elysia in forum C++ Programming
    Replies: 20
    Last Post: 07-05-2008, 04:59 AM
  2. string padding and replacement functions
    By George2 in forum Tech Board
    Replies: 4
    Last Post: 11-19-2006, 01:40 AM
  3. Prob with padding in BMP image files
    By tin in forum Game Programming
    Replies: 2
    Last Post: 01-09-2006, 08:23 AM
  4. Structure Padding, pragma pack...
    By P.Phant in forum C Programming
    Replies: 4
    Last Post: 06-04-2003, 06:56 AM
  5. Please help, internal compiler error
    By Cap in forum C Programming
    Replies: 5
    Last Post: 08-15-2002, 08:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21