急求!!此C++程序运行结果和原因
#include<iostream>usingnamespacestd;classA{public:A(){cout<<"A::A()called.\n";}virtua...
#include <iostream>
using 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";
buf=new char[i];
}
virtual ~B()
{ delete []buf;
cout<<"B::~B() called.\n";
}
private:
char *buf;
};
int main()
{ A *a=new B(15);
delete a;
return 0;
} 展开
using 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";
buf=new char[i];
}
virtual ~B()
{ delete []buf;
cout<<"B::~B() called.\n";
}
private:
char *buf;
};
int main()
{ A *a=new B(15);
delete a;
return 0;
} 展开
中智咨询
2024-08-28 广告
2024-08-28 广告
在当今竞争激烈的商业环境中,企业需要不断提高自身的竞争力,以保持市场份额和增加利润。通过人效提升,企业可以更有效地利用有限的资源,提高生产力和效益,从而实现盈利目标。中智咨询提供全方位的组织人效评价与诊断、人效提升方案等数据和管理咨询服务。...
点击进入详情页
本回答由中智咨询提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |