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. Managed C++/CLI
  4. How to wrap virtual functions?

How to wrap virtual functions?

Scheduled Pinned Locked Moved Managed C++/CLI
c++dotnettutorialquestion
4 Posts 3 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.
  • R Offline
    R Offline
    Rahim Rattani
    wrote on last edited by
    #1

    Consider a library (unmanaged) exports a class. the class is as follows. class A { public: virtual void funcA() { //do something } void DoProcessing() { // Do stuff funcA(); // Do Stuff } } Now in native, If i have to override funcA it would be as class DA : public A { public: virtual void funcA() { // related processing here. } } Now if i create an object of DA, and call DoProcessing() , funcA() in DA would be called. Now if I write a managed wrapper over class A as class _gc MngdA { private: A __nogc* m_pA; public: void DoProcessing() { m_pA->DoProcessing(); } } No if I inherit from MngdA, i dont have any path to override the virtual functions. This means DoProcessing() will always call the funcA() in class A. I need a mechanism, so that this virtual function call from the native could could be riuted out into managed code and be able to override it from clr languages.

    S N 2 Replies Last reply
    0
    • R Rahim Rattani

      Consider a library (unmanaged) exports a class. the class is as follows. class A { public: virtual void funcA() { //do something } void DoProcessing() { // Do stuff funcA(); // Do Stuff } } Now in native, If i have to override funcA it would be as class DA : public A { public: virtual void funcA() { // related processing here. } } Now if i create an object of DA, and call DoProcessing() , funcA() in DA would be called. Now if I write a managed wrapper over class A as class _gc MngdA { private: A __nogc* m_pA; public: void DoProcessing() { m_pA->DoProcessing(); } } No if I inherit from MngdA, i dont have any path to override the virtual functions. This means DoProcessing() will always call the funcA() in class A. I need a mechanism, so that this virtual function call from the native could could be riuted out into managed code and be able to override it from clr languages.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Well, C++/CLI also has virtual functions. As long as your managed wrappers also have the same inheritance hierarchy. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      R 1 Reply Last reply
      0
      • S S Senthil Kumar

        Well, C++/CLI also has virtual functions. As long as your managed wrappers also have the same inheritance hierarchy. Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        R Offline
        R Offline
        Rahim Rattani
        wrote on last edited by
        #3

        I think u dint got my question right. I have updated the question with further explanation if u could plz have a look. Rahim Rattani Karachi - Pakistan

        1 Reply Last reply
        0
        • R Rahim Rattani

          Consider a library (unmanaged) exports a class. the class is as follows. class A { public: virtual void funcA() { //do something } void DoProcessing() { // Do stuff funcA(); // Do Stuff } } Now in native, If i have to override funcA it would be as class DA : public A { public: virtual void funcA() { // related processing here. } } Now if i create an object of DA, and call DoProcessing() , funcA() in DA would be called. Now if I write a managed wrapper over class A as class _gc MngdA { private: A __nogc* m_pA; public: void DoProcessing() { m_pA->DoProcessing(); } } No if I inherit from MngdA, i dont have any path to override the virtual functions. This means DoProcessing() will always call the funcA() in class A. I need a mechanism, so that this virtual function call from the native could could be riuted out into managed code and be able to override it from clr languages.

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          You'd need managed wrappers for both base and derived classes for this particular scenario. Regards, Nish

          My blog : Nish’s thoughts on MFC, C++/CLI and .NET

          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