有以下程序 #include <iostream> #include <string> using namespace std class base { private: char baseName[10] public: base () { strcpy(baseName,'Base') } virtual char *myName() { return baseName } char *className() { return baseName } } class Derived : public base { private: char derivedName[10] public: Derived() { strcpy(derivedName,'Derived') } char *myName() { return derivedName } char *className() { return derivedName } } void showPtr(base &p) { cout<<p.myName () <<' '<<p.className () } int main () { base bb Derived dd showPtr(dd) return 0 } 运行后的输出结果为