Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. inheritance

inheritance

Scheduled Pinned Locked Moved C#
oopquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kalyan_2416
    wrote on last edited by
    #1

    hi all abstract class c { abstract function() } class c1:c { override fucntion() { // } void function() { } } class c2:c1 { c1 obj=new c1() obj.//how do i differenciate that i wanna call overrided function and ordinanry function of c1

    J 1 Reply Last reply
    0
    • K kalyan_2416

      hi all abstract class c { abstract function() } class c1:c { override fucntion() { // } void function() { } } class c2:c1 { c1 obj=new c1() obj.//how do i differenciate that i wanna call overrided function and ordinanry function of c1

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      c.function will always call the overrided method. You cannot call the base one. If that's what you want, don't use overrides, using hiding:

      class Base
      {
          public void Foo() { ... }
      }

      class Derived : Base
      {
         public new void Foo() { ... }
      }

      // Call the base one
      Base obj = new Base();
      obj.Foo();

      // Call the derived one
      Derived derived = new Derived();
      derived.Foo();

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Roman Catholic Relevance? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups