Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need help with crystal reports in VS 2008 Pin
eduardods10-Jun-10 20:02
eduardods10-Jun-10 20:02 
AnswerRe: Need help with crystal reports in VS 2008 Pin
V.10-Jun-10 21:11
professionalV.10-Jun-10 21:11 
AnswerRe: Need help with crystal reports in VS 2008 Pin
Mycroft Holmes11-Jun-10 22:04
professionalMycroft Holmes11-Jun-10 22:04 
QuestionHow to add images to a reportviewer ??? Pin
isaacrc8210-Jun-10 13:33
isaacrc8210-Jun-10 13:33 
Questionpopulating a treeview? Pin
User 251249410-Jun-10 6:05
User 251249410-Jun-10 6:05 
AnswerRe: populating a treeview? Pin
Mycroft Holmes11-Jun-10 22:08
professionalMycroft Holmes11-Jun-10 22:08 
QuestionList<T> Comparison [SOLVED] Pin
Paladin200010-Jun-10 4:58
Paladin200010-Jun-10 4:58 
AnswerRe: List Comparison Pin
DaveyM6910-Jun-10 5:10
professionalDaveyM6910-Jun-10 5:10 
GeneralRe: List Comparison Pin
Paladin200010-Jun-10 5:28
Paladin200010-Jun-10 5:28 
GeneralRe: List Comparison Pin
Hristo-Bojilov10-Jun-10 5:52
Hristo-Bojilov10-Jun-10 5:52 
AnswerRe: List Comparison Pin
Luc Pattyn10-Jun-10 5:30
sitebuilderLuc Pattyn10-Jun-10 5:30 
GeneralRe: List Comparison Pin
Paladin200010-Jun-10 5:39
Paladin200010-Jun-10 5:39 
GeneralRe: List Comparison Pin
#realJSOP10-Jun-10 6:36
professional#realJSOP10-Jun-10 6:36 
AnswerRe: List Comparison Pin
Paladin200010-Jun-10 5:58
Paladin200010-Jun-10 5:58 
GeneralRe: List Comparison Pin
Paladin200010-Jun-10 6:06
Paladin200010-Jun-10 6:06 
GeneralRe: List Comparison Pin
Luc Pattyn10-Jun-10 6:06
sitebuilderLuc Pattyn10-Jun-10 6:06 
AnswerRe: List Comparison Pin
Kevin McFarlane10-Jun-10 10:45
Kevin McFarlane10-Jun-10 10:45 
QuestionGoogle Maps Pin
JohnUSA10-Jun-10 2:53
JohnUSA10-Jun-10 2:53 
AnswerMessage Closed Pin
10-Jun-10 3:06
stancrm10-Jun-10 3:06 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:45
JohnUSA10-Jun-10 4:45 
AnswerRe: Google Maps Pin
Paladin200010-Jun-10 4:41
Paladin200010-Jun-10 4:41 
GeneralRe: Google Maps Pin
JohnUSA10-Jun-10 4:53
JohnUSA10-Jun-10 4:53 
GeneralRe: Google Maps Pin
Paladin200010-Jun-10 5:20
Paladin200010-Jun-10 5:20 
AnswerRe: Google Maps Pin
Adam R Harris10-Jun-10 4:52
Adam R Harris10-Jun-10 4:52 
QuestionTricky Inheritance Question Pin
Jon Myers10-Jun-10 2:47
Jon Myers10-Jun-10 2:47 
OK, this program is from a class I'm taking, it's an example out of our book. You have four classes, D inherits from C, C from B and B from A. I kind of understand how this works but I'm not sure.

Question. Is this considered a single object? Only one object is created but do the references make the other classes(or the methods within them) part of the same object?

I think I understand the rest.
1.) D is called and outputs 'D' becuase that is the method within D.
2.) Since C is virtual and it's child class D overries it, C also outputs 'D'.
3.) Since C is declared 'new' that hides C from B (I assume it also hides D from B) and therefore B outputs it own method and displays 'B'
4.) A is virtual and since its child class B overrides it, it also outputs 'B'.

Sorry, but I think my brain actually froze for a while when I was trying to figure this out and I'm just trying to see if anyone has any input or knows if I'm right.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example
{
    class A
    {
        public virtual void M() { Console.WriteLine("A"); }
    }

    class B : A
    {
        public override void M() { Console.WriteLine("B");  }
    }

    class C : B
    {
        new public virtual void M() { Console.WriteLine("C"); }
    }

    class D : C
    {
        public override void M() { Console.WriteLine("D"); }
    }

    class Program
    {
        static void Main(string[] args)
        {
            D d = new D();
            C c = d;
            B b = c;
            A a = b;

            d.M();
            c.M();
            b.M();
            a.M();
        }
    }
}

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.