http://blog.csdn.net/ly21st http://ly21st.blog.chinaunix.net
分类: C/C++
2011-11-30 13:46:34
#include
using namespace std;
struct Base {
static void statmem() {}
};
struct Derived:Base {
void f(const Derived &);
};
void Derived::f(const Derived &derived_obj)
{
void *p;
p=(void*)Base::statmem;
cout<<"基类中的静态函数地址:"<
p=(void*)Derived::statmem;
cout<<"派生类中的静态函数地址1:"<
p=(void*)derived_obj.statmem;
cout<<"派生类中的静态函数地址2:"<
p=(void*)statmem;
cout<<"派生类中的静态函数地址2:"<
}
int main()
{
Derived obj;
obj.f(obj);
void *p;
p=(void*)&obj;
cout<
getchar();
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
******************************************************************
运行结果:
基类中的静态函数地址:0x410b20
派生类中的静态函数地址1:0x410b20
派生类中的静态函数地址2:0x410b20
派生类中的静态函数地址2:0x410b20
对象obj的地址为:0x22ff77