Copying a class copies the member functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Apropos my recent questions regarding passing by reference etc the following question comes to mind:

When a class instance is created, does this also create a copy in memory (from the class prototype) of the member functions or only of the data members?

Regarding static member functions I realize there is no meaning to have an instance of the member function for each instance since the function does not relate to an instance of the class.

But even regarding non-static functions, I don't see any meaning in having an instance of the function for each member of the class, since all such functions would do basically the same thing, though with their parent instance only.

So what's the fact here? Is there any need for new copies of member functions with each new instance of a class being created? *Are* such new copies created by good compilers like GCC?

Thanks again for all your good and patient responses.

Shriramana Sharma.

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux