private
C++ Specific —>private: [member-list]private base-classWhen preceding a list of class members, the private keyword specifies that those members are accessible only from member functions and friends of the class. This applies to all members declared up to the next access specifier or the end of the class.When preceding the name of a base class, the private keyword specifies that the public and protected members of the base class are private members of the derived class.Default access of members in a class is private. Default access of members in a structure or union is public.Default access of a base class is private for classes and public for structures. Unions cannot have base classes.For related information, see friend, public, protected, and Table of Member Access Privileges.
也主是说,这些方法和属性都成了派生(derived class)类的Private方法和属性。一个对象难道不能调用自已的私有方法和属性吗,可以编译作了正确的操作,没有问题。 
:)

解决方案 »

  1.   

    跟你实际一点的讲一下:
    为什么以上代码在bcc32下能通过编译?
    我认为,derived类是私有继承了base类,那么在子类中,base::f()就应该是private属性,对子类是不可见的,但编译却没问题.如果,你是protected,那么base::f()就可以写成f(),这就是“derived类是私有继承了base类”和 derived类是保护继承了base类 这应用上的区别,明白了吗?西西,给我点分行吗:)
      

  2.   

    补充一下:
    你其实并没有直接存取base类的私有成员,你的疑惑可能在这里
    void f() const
            {
            cout<<"in derived f()"<<endl;
            base::f();<——这里   对吗?
            }你是通过base才存取基类的私有成员的,关键是“base::f();<——”里的“base”
    能多加一点分给我吗?:)
      

  3.   

    同意hujun614(胡均)和lj1023(清风)的意见。
      

  4.   

    hujun614(胡均) and lj1023(清风) are right