wrapper classes?

This is a discussion on wrapper classes? within the C++ Programming forums, part of the General Programming Boards category; What are wrapper(sp?) classes? I have heard the term used but do not know what it means. Ehh maybe I ...

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    wrapper classes?

    What are wrapper(sp?) classes? I have heard the term used but do not know what it means.


    Ehh maybe I should look in the FAQ.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    They wrap around an API. So you can write a program using a wrapper class for sockets on linux. and you can write a same wrapper class for sockets for windows, and use your program without changing it.

    it would have obvious functions like
    write(...);
    read(...);
    open(...);
    close(...);

    which would in turn call the platform-specific api.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    So to create a wrapper class you need to understand the API first.
    I just queried the FAQ.

    I started learning the Win32 API from Charles Petzold's book and thought how can I turn this from C into C++. I guess one needs to implement wrapper classes.

    Are there any books that step through the process of creating wrapper classes especially for the Win32 API?

    I am not looking for a lesson on MSFC though, rather on how to implement my own wrapper classes.

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Most of the api calls are already wrapped in C++ classes, but if you really want to wrap everything, you might end up with a lot of grey hair ... in about 20 years or so - when you're finished.
    [code]

    your code here....

    [/code]

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    A wrapper class does not neccessarily have to wrap around an entire API. for example this could be a simple (pointless, although needed in Java) wrapper class. This class is a wrapper for the primitive type 'int'

    Code:
    class Integer {
        int i;
    public:
        Integer() { i = 0; }
    
        int intValue() { return i; }
        /* etc ... */
     
    };

  6. #6
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by Perspective
    A wrapper class does not neccessarily have to wrap around an entire API.
    I merely pointed out that it could take a bit longer to wrap the entire windows API and that partial implementations already exist.
    [code]

    your code here....

    [/code]

  7. #7
    That Creepy Network Guy DeepBlackMagic's Avatar
    Join Date
    Feb 2003
    Posts
    265
    Speaking of a berkley sockets wrapper, would any of you guys have one handy?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wrapper classes
    By Know_Your_Role in forum C++ Programming
    Replies: 17
    Last Post: 06-10-2009, 02:24 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 05:30 PM
  3. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 11:47 AM
  4. WinAPI wrapper classes
    By Hunter2 in forum Windows Programming
    Replies: 8
    Last Post: 12-14-2004, 05:22 PM
  5. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 08:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21