• Advertisement

Archived

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

GCC, member function pointer and HINSTANCE

This topic is 5507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Ooops... my typing error. In Microsoft/Borland, it need not require the ''&''. i.e.:
foo << Foo::SomeFunc;
whereas GCC requires:
foo << &Foo::SomeFunc;
...again.. still wierd.

Share this post


Link to post
Share on other sites

  • Advertisement