i have these 2 classes
class Animal
{
public string name;
public virtual void MakeSound()
{
Console.WriteLine("some sound");
}
}
class Dog : Animal
{
public override void MakeSound()
{
Console.WriteLine("bark");
}
}
id like to know where the differences are between these 2 objects?
Animal dog = new Dog();
Dog dog2 = new Dog();
edit: my problem with this is that i do not understand the process/ thought behind these 2 object. Yes, they both are Dog() object, but what I do not understand WHY i have the possibility to assign Animal AND Dog to the type. I get that "assign" is the wrong wording but what it just seems VERY weird to me that I have the possibility to do that.
Programming has treated me "harshly" until now. Everything has to have the right syntax and everything has to be in the right order and everything hast to make sense. If thats not the case i get an error
List<int> list = new List<int>; doesn't work, neither does List<int> list = new List(); nor something else. Thats why I don't get the 2 objects. It seems to me that, functionality wise, they both do and can do the same. But are they actually the same?