Sunday, 8 September 2013

Why would I put a reference of class2 into an object of class1?

Why would I put a reference of class2 into an object of class1?

Ok, so I've come across this code snippet:
class1 a = new class1();
a.Test();
class1 b = new class2();
b.Test();
It had something to do with virtual and override, but my question now is:
Why type
class1 b = new class2();
when you could just type
class2 b = new class2();

No comments:

Post a Comment