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.
I'm not sure what you're trying to do. Maybe this?
A one = new A(); Ab two = (Ab)one;
That won't work because one is an instance of A which IS NOT an Ab. If you really need an Ab you might do what you suggested:
Ab two = new Ab(one);
This is a good time to ask yourself if "extends" was the right way to define Ab. An alternative is to make Ab just extend Object, hold a reference to an A instance, and pass any method calls through to that instance. For polymorphism you could make A and Ab implement the same interface for the methods on A.
Does that fit the problem?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
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
subject: instantiation of an extended type with baseclass