Re: Question about memory allocation

Discussion in 'C++' started by John, Nov 23, 2004.

  1. John

    John Guest

    Jack Klein <> wrote in message news:<>...
    > On 21 Nov 2004 08:50:45 -0800, (John) wrote in
    > comp.lang.c++:
    >
    > > Following is a simple class:
    > >
    > > class myclass{
    > > public:
    > > int AA[20000];
    > > char BB[10000];
    > > }
    > >
    > > The size of an object of myclass is 4*20000+10000. That is to say, an
    > > object of myclass occupies the memory of (4*20000+10000) bytes.
    > > My question is:
    > > Is the memory allocated to AA adjacent to the memory allocated to BB?

    >
    > What exactly do you mean by adjacent? There are several ways the term
    > could be applied.
    >
    > If you mean is the address of BB[0] exactly equal to the (invalid)
    > address of AA[20000]? In that case, the answer is that it is up to
    > your compiler, and perhaps options that you specify to the compiler.
    > The language allows the implementation to place padding between any
    > two members of a structure or class, or after the last member. Any
    > place, in fact, except before the first member.
    >


    Could you show me a compiling option with g++ compiler?

    Thanks.

    John
    John, Nov 23, 2004
    #1
    1. Advertising

  2. John wrote in news: in
    comp.lang.c++:

    >> If you mean is the address of BB[0] exactly equal to the (invalid)
    >> address of AA[20000]? In that case, the answer is that it is up to
    >> your compiler, and perhaps options that you specify to the compiler.
    >> The language allows the implementation to place padding between any
    >> two members of a structure or class, or after the last member. Any
    >> place, in fact, except before the first member.
    >>

    >
    > Could you show me a compiling option with g++ compiler?
    >


    You are unlikely to get an answer here, our expertise is
    in Standard C++, for gcc help goto:

    news:gnu.gcc.help

    or

    news:gnu.g++.help

    HTH.

    Rob.
    --
    http://www.victim-prime.dsl.pipex.com/
    Rob Williscroft, Nov 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    679
    Eric Sosman
    Mar 22, 2005
  2. Rodrigo Dominguez

    memory allocation and freeing memory

    Rodrigo Dominguez, Jun 13, 2005, in forum: C Programming
    Replies:
    11
    Views:
    580
    Jean-Claude Arbaut
    Jun 15, 2005
  3. Ken
    Replies:
    24
    Views:
    3,834
    Ben Bacarisse
    Nov 30, 2006
  4. chris
    Replies:
    6
    Views:
    971
    chris
    Oct 28, 2005
  5. Bjarke Hammersholt Roune
    Replies:
    14
    Views:
    1,170
    Bjarke Hammersholt Roune
    Mar 6, 2011
Loading...

Share This Page