Thread: Location of member functions in memory

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Location of member functions in memory

    Consider the following class:
    Code:
    class A
    {
        int Aint;
        void Afunc(void);
    };
    
    void A::Afunc(void)
    { return; }
    The sizeof A is 4. The sizeof Aint is 4. Where is the code of Afunc stored when I make an instance of A? Also, is that code replicated for each instance of A, or is there just one set of code?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Well what do you think would make most sense from the information that you have worked out?
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    1,619

    Re: Location of member functions in memory

    Originally posted by bennyandthejets

    is there just one set of code?
    Why would you ever need to have more than one set of code?
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Yeah that fits. I think what I need right now is a description of the structure of an executable. I remember seeing that somewhere, so I will take a look around.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Remember that C++ member functions are just like C functions except they "this" passed to em implicitly.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modules and Member Functions
    By arrgh in forum C++ Programming
    Replies: 2
    Last Post: 05-07-2008, 02:46 AM
  2. Static functions.... why?
    By patricio2626 in forum C++ Programming
    Replies: 4
    Last Post: 04-02-2007, 08:06 PM
  3. member functions can't see private data members
    By ichijoji in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2006, 02:36 PM
  4. issue with member functions
    By Chaplin27 in forum C++ Programming
    Replies: 4
    Last Post: 09-27-2006, 09:18 PM
  5. Pointer's
    By xlordt in forum C Programming
    Replies: 13
    Last Post: 10-14-2003, 02:15 PM