Created
January 31, 2013 02:21
-
-
Save grissiom/4679382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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