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. overriding members?

overriding members?

Scheduled Pinned Locked Moved C#
question
3 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.
  • N Offline
    N Offline
    NaNg15241
    wrote on last edited by
    #1

    Class C { } Class A { Private C; } Class D : C { } Class B : A { Private D; } It comes to this that when I have a member of type B, I have also C and also D in it. How can I override C in it? Thanks alot for the helpers :) NaNg.

    M 1 Reply Last reply
    0
    • N NaNg15241

      Class C { } Class A { Private C; } Class D : C { } Class B : A { Private D; } It comes to this that when I have a member of type B, I have also C and also D in it. How can I override C in it? Thanks alot for the helpers :) NaNg.

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Use virtual keyword for C.

      Mazy
      "This chancy chancy chancy world."

      N 1 Reply Last reply
      0
      • M Mazdak

        Use virtual keyword for C.

        Mazy
        "This chancy chancy chancy world."

        N Offline
        N Offline
        NaNg15241
        wrote on last edited by
        #3

        It sais "invalid modifier 'virtual' for C". I'll try Explaining again... I have these classes: public Class C { } public abstract Class A { protected C; } public Class D : C { } public Class B : A { private D; } When I do this: B = new B();, I have D AND C in B. And I need ONLY ONE, which is the newer one - D. How can I make the Class A use the new one (D) insted of the old one?

        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