题海让大学四年没有难题
白天模式登陆

题目详情

单选题 Analyze the following program:#include <iostream>using namespace std;class AA {public: AA( ) { t( ); cout << "i from AA is " << i << endl; } void t( ) { setI(20); } virtual void setI(int i) { this->i = 2*i; } int i;};class BB: public AA {public: virtual void setI(int i) { this->i = 3*i; }};int main( ) { AA *p = new BB( ); return 0;}

A. The constructor of class AA is not called

B. The constructor of class AA is called and it displays "i from AA is 0"

C. The constructor of class AA is called and it displays "i from AA is 40"

D. The constructor of class AA is called and it displays "i from AA is 60"

C++语言程序设计课程封面

学科:C++语言程序设计

时间:2025-12-18 02:35:52

Copyright © 2022 津ICP备2021001502号