Skip to content

Instantly share code, notes, and snippets.

@grissiom
Created January 31, 2013 02:21
Show Gist options
  • Save grissiom/4679382 to your computer and use it in GitHub Desktop.
Save grissiom/4679382 to your computer and use it in GitHub Desktop.
#include <stdio.h>
class A
{
public:
virtual float getz()
{
return 0.0;
}
};
class B : public A
{
public:
virtual float getz()
{
return 1.0;
}
};
int main(int argc, char* argv[])
{
B b;
printf("%d\n", b.getz());
printf("%p\n", &(b.getz));
return 0;
}
======================
~% g++ tmp.cpp
tmp.cpp: 在函数‘int main(int, char**)’中:
tmp.cpp:26:25: 错误:ISO C++ 不允许通过取已绑定的成员函数的地址来构造成员函数指针。请改用‘&B::getz’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment