![]() |
#2
rjsp2017-03-13 18:14
|

#include <iostream>
using namespace std ;
class Base {
public:
static void statmem( ) ;
};
class Derived :public Base {
public:
void f( const Derived& ) const ;
};
void Derived::f(const Derived& derived_obj) const {
cout << "调用常量成员函数" << endl;
Base::statmem( ) ;
Derived::statmem() ;//Derived继承了statmem
//派生类的对象能访问基类的静态成员
derived_obj.statmem(); //通过Derived对象访问
statmem( ) ;//通过this对象访问
}
void Base::statmem() {
cout << "访问" << endl ;
}
int main( )
{
const Derived constobj ;
constobj.f( constobj ) ;
return 0 ;
}
这里statmem( ) ;//通过this对象访问,注释写通过this对象访问,没搞懂啊,静态成员函数statmem( )是没有this的啊