写出下面程序的运行结果。 #include <iostream> using namespace std; class Base { public: void Who( ){cout<<"class Base"<<endl;} }; class Derived1:public Base { public: void Who( ){cout<<"class Derived1"<<endl;} }; class Derived2:public Base { public: void Who( ){cout<<"class Derived2"<<endl;} }; int main( ) { Base obj1,*p; Derived1 obj2; Derived2 obj3; p=& obj1; p->Who(); p=& obj2; p->Who(); p=& obj3; p->Who(); obj2.Who(); obj3.Who(); return 0; } ______ ______ ______ ______ ______
举一反三
- 有以下程序: #include <iostream> using namespace std; class Base{ public: Base(int x=0) {cout<<x;} }; class Derived : public Base{ public: Derived(int x=0) {cout<<x;} private: Base val; }; int main(){ Derived d(1); return 0; } 程序的输出结果是
- Python 语句print(type(1//2))的输出结果是: A: <class ‘int’> B: <class ‘float’> C: <class ‘list’> D: <class ‘str’>
- Python语句print(type(1/2)的输出结果是哪一项?( ) A: <class 'int'> B: <class 'number'> C: <class 'float'> D: <class 'double'>
- print(type(lambda:3))的输出结果是? <class 'float'>|<class 'NoneType'>|<class 'function'>|<class 'int'>
- Python语句print(type(['a','1',2,3]))的输出结果是哪一项? A: <class 'list'> B: <class 'disc'> C: <class tuple' > D: <class 'set'>