Word line classes

Discussion in 'C' started by priyatendulkar, Jul 26, 2011.

  1. priyatendulkar

    priyatendulkar New Member

    Joined:
    Jun 20, 2011
    Messages:
    20
    Likes Received:
    1
    Trophy Points:
    0
    hi,

    I want to know whether compiler implements bits padding in Classes as in structs??

    eg:
    if my struct is

    struct info
    {
    char c;
    int i;
    };
    Size of this structure would be 8 and not 5..(considering int is 4 bytes)


    On similar grounds if my class is
    class info
    {
    public:
    char c;
    int i;
    };
    Size of this class would be 8 always?
     
  2. Scripting

    Scripting John Hoder

    Joined:
    Jun 29, 2010
    Messages:
    421
    Likes Received:
    57
    Trophy Points:
    0
    Occupation:
    School for life
    Location:
    /root
    the first one's size is 5 not 8 and the 2nd one's size is also 5 i think, 'couse public doesn't change anything.
     
  3. priyatendulkar

    priyatendulkar New Member

    Joined:
    Jun 20, 2011
    Messages:
    20
    Likes Received:
    1
    Trophy Points:
    0
    Hello Scripting,

    Thanks for the reply..
    However,the size of structure would be 8 as 3 bytes would be padded after "char c" member
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice