473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Explanation of wrapper class

Can someone explain the function of a wrapper class and maybe an
example? Thanks.

Jun 18 '06 #1
2 1464
<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
Jun 18 '06 #2
Joanna, thanks for the explanation and example!
Joanna Carter [TeamB] wrote:
<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


Jun 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I was wondering what would be the most elegant way for creating a Python class wrapper for a command line utility, which takes three types of arguments: 1. options with values (--foo=bar)...
12
by: Egil M?ller | last post by:
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for...
4
by: Christian Christmann | last post by:
Hi, I need an STL list and was thinking of putting the list in wrapper class. The reason for my decision is that you can much better perform consistency checks. For instance, I need a...
1
by: sureshjram | last post by:
Hi all , What is a Wrapper Class in c#?? I am new to this OOPS plz explain it thanks in advance regards Suresh
0
by: DotNetJunkies User | last post by:
Background: I am creating a VC++ .NET wrapper for a C++ DLL; the aim is to use this wrapper in C# as shown below: Range r = new Range( 2, 2 ); r = new Cell( “Hello Mum†); Range is a...
9
by: WithPit | last post by:
I am trying to create an Managed C++ Wrapper around an unmanaged library which contains C++ code. Some of the unmanaged methods returns an returntype which is of the abstract base type (for...
2
by: Christian Chrismann | last post by:
Hi, an application uses a wrapper class for an STL list. Basically, this template class provides the same functions (delete, append, find...) as an ordinary STL list. Additionally, there are...
16
by: utab | last post by:
Dear all, In programming terminology, what is a wrapper and where is it used? Regards
0
by: Ed | last post by:
Hi, dear all, I want to wrapper the legacy C++ Template Class to be used by the C# code, so I try to wrapper the legacy C++ code into CLI/C++ code first. One problem is how to wrapper C++...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.