<so*********@yahoo.com> a écrit dans le message de news:
11**********************@h76g2000cwa.googlegroups. com...
| Can someone explain the function of a wrapper class and maybe an
| example? Thanks.
The Wrapper pattern is also known as the Adapter patern and this is
basically what it does; adapt one class to another purpose.
One of many useful ideas for using the Wrapper pattern is when you want to
extend a class that only has non-virtual methods :
public class NonVirtual
{
public void DoSomething()
{
...
}
}
public class VirtualAdapter
{
private NonVirtual realObject = new NonVirtual();
public virtual void DoSomething()
{
realObject.DoSomething();
}
}
Now DoSomething() can be polymorhically overridden in derived classes.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer