Wha is a "Wrapper class" and what is it used for?

X-Istence

*
Political User
Joined
Dec 5, 2001
Messages
6,498
#2
Sometimes you have an object that already does what you need to it to do, for example the GTK+ library.

Now, you come along and already have this great app that interfaces to Windows using another class.

Now you want to port that program to GTK+, you write a small wrapper around GTK+ that implements the functions required, and swap out the Windows class with the GTK+ class, and now your program has GTK+ as it's window drawing tool, and the class essentially is like a wrapper around a candy bar. It protects and provides a clean way to access the underlying candy!
 

Geffy

OSNN Veteran Addict
Joined
Mar 18, 2002
Messages
7,805
#3
Its an abstraction tool for isolating your code from the complicated inner workings of something else.

In Java you have the Integer wrapper class which isolates your code from the inner workings of the 'int' data type.
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Hey ep!

All good with me, applying for microsoft mvp right now, should have done this a while ago.

Notifications don't work, I only found your response by comming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier, mine is perriscalderon at gmail
Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...

Forum statistics

Threads
62,011
Messages
673,481
Members
89,035
Latest member
mkifyyjim