题目内容
(1)写出程序的运行结果。#includeusing namespace std;class Stock{public:void print(){cout<<"Stock class.\n";}};class Der1_Stock:public Stock{public:void print(){cout<<"Der1_Stock class.\n";}};class Der2_Stock:public Stock{public:void print(){cout<<"Der2_Stock class.\n";}};int main(){Stock *ptr,s1;Der1_Stock d1;Der2_Stock d2;ptr=&s1;ptr->print();ptr=&d1;ptr->print();ptr=&d2;ptr->print();return 0;}(2)修改上一题的程序,使运行结果为:Stock class.Der1_Stock class.Der2_Stock class.
查看答案
搜索结果不匹配?点我反馈
更多问题