Results 1 to 2 of 2

Thread: Virtual Calls with Non-Virtual Methods

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Virtual Calls with Non-Virtual Methods

    I'm working on implementing an abstract class (intended to be inherited only) that contains a polling method for data integrity. The polling method will call an actor method as one of the initial statements to check for user changes to the class's members. However the behavior for the actor method can't be static (i.e. defined in the abstract class alone) because for each child class based on this abstract class, the behavior for this method won't be the same in about 90% of situations. The obvious answer here was to override the method for each child class.

    However something struck me as I was thinking about this. The polling method will initially make a call to the virtual actor method to better adjust the data integrity. Now what I'm curious about is when the polling method makes the call to the virtual actor method, will it execute the actor method that was defined with the child class (i.e. the overridden actor method) or will it make a call to the actor method defined with the base class?
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Virtual Calls with Non-Virtual Methods

    As far as I am aware, it will always call the overridden methods unless explicitly called from within your overridden method.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width