By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,571 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,571 IT Pros & Developers. It's quick & easy.

Overhead base class versus derived class method invocation

P: n/a
I want to know incase there is any performance difference or overhead
in calling a base class method and a derived class method.

Basically I am talking about simple method that is not overridden nor
virtual. If I declare a method in the base class say M1() and another
in derived class M2(). Then I make a derived class object derived. I
then invoke these:

derved.M1()
derived.M2()

What difference would it be.

Also does the size of the class object increase with more method
members in the class. Incase I add methods to the base class would it
increase the size of the derived class also.

Thankx in advance to you all.

Dec 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Basically, nothing. There would be a lookup in the method table for the
object, and then it would be executed.

Honestly, it's not even something to be concerned about.

The size of the ^type^ will increase with each member in the class, as
well as any derived classes. However, you ^REALLY^ shouldn't worry about
this. Unless you had hundreds of members though. However, at this point, I
wouldn't be worried about performance (it still wouldn't be an issue), but
because of design (one type with that many members is excessive, and poorly
designed).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"question" <ja********@rediffmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I want to know incase there is any performance difference or overhead
in calling a base class method and a derived class method.

Basically I am talking about simple method that is not overridden nor
virtual. If I declare a method in the base class say M1() and another
in derived class M2(). Then I make a derived class object derived. I
then invoke these:

derved.M1()
derived.M2()

What difference would it be.

Also does the size of the class object increase with more method
members in the class. Incase I add methods to the base class would it
increase the size of the derived class also.

Thankx in advance to you all.

Dec 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.