#include <iostream>
using namespace std;
class Base
{
public:
Base() : n(10) { }
std::size_t size() const { return n; }
protected:
std::size_t n;
};
class Derived : private Base
{
public:
using Base::size;
public:
using Base::n;
};
int main(int argc, char *argv[])
{
Derived objD;
Base objB;
cout << objD.size() << endl;
// cout << objB.n << endl;
cout << objD.n << endl;
return 0;
}
运行结果:
10
10