linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shriramana Sharma <samjnaa@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Copying a class copies the member functions?
Date: Sun, 08 Apr 2007 20:50:54 +0530	[thread overview]
Message-ID: <46190856.1010207@gmail.com> (raw)

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.


             reply	other threads:[~2007-04-08 15:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-08 15:20 Shriramana Sharma [this message]
2007-04-13 17:21 ` Copying a class copies the member functions? Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46190856.1010207@gmail.com \
    --to=samjnaa@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).