Menu

overloading pointers to functions

2003-01-28
2012-09-26
  • Nobody/Anonymous

    is it even possible? in the example i want to use b as all the a function to where it points. please help

    #include <iostream>

    #include <stdlib.h>

    using namespace std;

    void a ( void )

    {

    cout << "None!" << endl;

    }

    void a ( int a )

    {

    cout << a << endl;

    }

    void a ( int a, int b )

    {

    cout << a << endl << b << endl;

    }

    int main ()

    {

    void ( * b ) ( ) = a;

    b ();

    system ( "pause" );

    return 0;

    }

     
    • Patrick Ogay

      Patrick Ogay - 2003-01-29

      I think with classes you can do, what you like.
      Patrick

       
    • Anonymous

      Anonymous - 2003-01-29

      It 's not good style,but It can implement!
      try
      reinterpret_cast<void (*)(int)>(b)=a;

      reinterpret_cast<void (*)(int)>(b)(100);
      reinterpret_cast<void (*)(int,int)>(b)=a;

      reinterpret_cast<void (*)(int,int)>(b)(100,500);

       
    • Curtis Sutter

      Curtis Sutter - 2003-01-29

      I did have this type of code, unfortunantly it was on my main computer, which died.  It was in the "Button" class for the xGDI which Zero and I were working on.
      Zero, I sent you that code for my options class, do you still happen to have it?  It would be really nice since the newest version I have now, has a noworking ComboBox class.  It took me a long time to get that combo box working like it should.

      Curtis

       
    • Nobody/Anonymous

      Any positive news on recovering your main machine?

      Wayne

       
    • Curtis Sutter

      Curtis Sutter - 2003-01-29

      Not yet, I really screwed things up.  You see I'm more software, not hardware.  So when Win98 SE took all of my NTFS partitions (with the non-replacable data) and turned it into one *empty* partition, I flipped.  I re-boot partition magic 7.0 (from boot disks) and tried to un-delete that partition.  Since you can't un-delete and good partition, I had to delete it first.  So I deleted that partition, which really screwed up my partition table...  make a long story short, use the right tools for the job, and have someone that knows more than you fix your computer at the first sing of trouble.  If I hadn't deleted and tried to un-delete that partition, I'd have my main comp back righ now, with all the info restored.  I have faith in my friend, he has recovered partitions from a dual RAID 0 set-up.  Anyhow, he is getting some more software from a friend, same stuff the cops use on crimials HDs.
      No positive news yet, I'll keep up posted.

      Curtis

       
    • Nobody/Anonymous

      no, I am afraid I don't have it. sorry... you were making so many changes i didnt really see the point..

      Zero Valintine

       
    • Curtis Sutter

      Curtis Sutter - 2003-01-29

      np.  I may be able to re-write it in a week or so...

      Curtis

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.