题目内容

写出下面程序的运行结果。#includeusing namespace std;class A{ public:A( ){ cout<<"A::A()called.\n"; }virtual ~A( ){ cout<<"A::~A()called.\n"; }};class B:public A{ public:B(int i){ cout<<"B::B()called.\n";buffer=new char[i]; }virtual ~B( ){ delete []buffer;cout<<"B::~B()called.\n"; }private:char* buffer;};void fun(A* a){ delete a; }int main(){ A *b=new B(10);fun(b);return 0;}程序的运行结果是:__________________________________________________________

查看答案
更多问题

写出下面程序的运行结果。#includeusing namespace std;class Shape{public:void Draw(){cout<<"Shape"<Draw();c.Print();sp2.Draw();r.Print();}程序的运行结果是:__________________________________________________

如果要把类B的成员函数void fun()说明为类A的友元函数,则应在类A中加入语句_______________。

给出下面程序输出结果。#include class example{int a;public:example(int b=5){a=b++;}void print(){a=a+1;cout <

类定义中的成员默认的访问权限是private。()

A. 对
B. 错

答案查题题库