Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Polymorphism with Interfaces

Status
Not open for further replies.

Stephen87

IS-IT--Management
Nov 18, 2006
4
US
I am trying to understand a hard to grasp concept. If any of you will give me pointers, it will be much appreciated.

Say there is a class Document with two members
void Read();
void Write();

Now there is another class called Note, and it inherits Document class
override Read();
new void Write(); //Emphasis on 'new'

Now say I create a new Document reference, and have it refer to a new Note object (which inherits Document)
Document doc=new Note();

Then I try doc.Write, and here is where I am confused. When I implement doc.Write, why would it not use the 'new' Write()? It uses Document.Write, not Note.Write when I specifically specified new on the Write in Note.
 
The new modifier will use the correct method. You must have a typo. Post your code. You might try not using reserved words.
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top