S source_acct Jun 18, 2006 #1 Can someone explain the function of a wrapper class and maybe an example? Thanks.
J Joanna Carter [TeamB] Jun 18, 2006 #2 <[email protected]> a écrit dans le message de (e-mail address removed)... | 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
<[email protected]> a écrit dans le message de (e-mail address removed)... | 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