471,585 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

Overhead base class versus derived class method invocation

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
1 1440
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.

Similar topics

5 posts views Thread by Andy | last post: by
7 posts views Thread by relient | last post: by
5 posts views Thread by Dennis Jones | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.