0
Can someone explain me the difference between this?
Shape c = new Circle(); //this and Circle c = new Circle(); Im currently at polymorphism part, i don't understand how this affect the final result of the object properties Also sorry if my english is kind of weird my native language is spanish.
1 Odpowiedź
+ 3
Did you get to the last section of the polymorphism lesson?
https://www.sololearn.com/learn/CSharp/2681/
Take into consideration the following code where you can use 1 variable of the parent class to instantiate any of its child classes.
Shape c = new Circle();
c.Draw();
c = new Rectangle();
c.Draw();
Circle cir = new Circle();
cir.Draw();
// this produces an error
// cir = new Rectangle();