This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, That's right, a Tree cannot be a Redwood; although, a Redwood can be a Tree.
Not sure where "line 10" is in your example... but see if this clears is up for you. It's all about the references.
Tree t = new Tree( ) can never be downcast to a Redwood.
Tree tr = new Redwood( ) can be downcast to a Redwood.
Remember, the object never changes, but it's "references" do. And object is an object is an object. A Tree will always be a Tree. A Redwood will always be a Redwood. You can't change that. You can only change the references.
Hope I'm not wrong, but that's how I see it.
Joined: Feb 01, 2007
Thanks for the explanation. that cleared my query on references
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com