Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Wrapper Class

Wrapper Class

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Benjamin Bruno
    wrote on last edited by
    #1

    Hi How to create a wrapper class for an existing class? thanks : :^)

    S N _ A 4 Replies Last reply
    0
    • B Benjamin Bruno

      Hi How to create a wrapper class for an existing class? thanks : :^)

      S Offline
      S Offline
      Sauro Viti
      wrote on last edited by
      #2

      Your question is too generic: it depends on your scenario. Which kind of class do you want to wrap (COM object, ActiveX, ...)? What is your target?

      1 Reply Last reply
      0
      • B Benjamin Bruno

        Hi How to create a wrapper class for an existing class? thanks : :^)

        N Offline
        N Offline
        Niklas L
        wrote on last edited by
        #3

        Typically what you do is to create a new class exposing methods of an interface that you are interested in. Depending of what you want to wrap, the interface might be a C header file, a COM interface or another class, etc. The wrapper class often manages resource allocation and deallocation of the exposed interface, and this is often the most valuable aspect of wrapping. You can also make it easier to use the interface by bundling methods together as you see fit, removing rarely used parameters and such.

        home

        1 Reply Last reply
        0
        • B Benjamin Bruno

          Hi How to create a wrapper class for an existing class? thanks : :^)

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          As a member of the wrapper class, an object of the existing class is created. The member object is then initialized in the constructor of the wrapper class. From the methods of the wrapper class, the methods of the existing class will be called using the member object.

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          1 Reply Last reply
          0
          • B Benjamin Bruno

            Hi How to create a wrapper class for an existing class? thanks : :^)

            A Offline
            A Offline
            Aescleal
            wrote on last edited by
            #5

            The problem here is that one man's wrapper is another's bridge, adapter, guard or facade. Generally you use wrappers to modify the functionality of the wrapped class in some way so how you do it depends on what the class you're wrapping does and what you want the wrapper to do. If I were you I'd have a look at a book on design patterns - e.g. "Design Patterns" by Gamma, Helm, Johnson and Vlisides - and go through the patterns looking at which of the classes used are just there to modify the behaviour of other classes by containing them rather than by extending them. Cheers, Ash

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups