Archived

This topic is now archived and is closed to further replies.

DerekSaw

GCC, member function pointer and HINSTANCE

Recommended Posts

Yesterday I got DevC++/GCC3.2. However I can't get this to compile whereas Microsoft/Borland compilers work absolutely fine (no error, no warning... All errors/warnings turn on):
    
class Foo
{
public:
  Foo() { }
  void SomeFunc() { do something }

  Foo& operator<< ( void (Foo::*method)() ) 
  { 
    (this->*method)();
    return *this;
  }
};

Foo foo;
foo << Foo::SomeFunc;  // ok in Microsoft/Borland, but error in GCC.

    
Besides this, I found out that the hInstance member of WNDCLASSEX and WNDCLASS is HANDLE type. Shouldn't it be HINSTANCE type? Nowonder I got this error "unable to convert to 'void*' from 'HINSTANCE__*'".... hmm.... wierd. [EDIT] Miss a bracket. [edited by - DerekSaw on December 23, 2002 8:11:14 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

  
class Foo
{
public:
Foo() {}
void SomeFunc() {}

Foo& operator<< (void (Foo::*method)()) { // missing )

(this->*method)();
return *this;
}
};

int main()
{
Foo foo;
foo << &Foo::SomeFunc; // missing &

return 0;
}


The above works in gcc3.1.

Share this post


Link to post
Share on other sites