各位大哥,帮我看个题!!!谢谢啦
帮我看看这个程序的运行结果是什么?#include <iostream.h>
#include <string.h>
class A{
public:
A(int i=0){a=i;}
virtual void print()
{ cout<<a<<endl;}
vitrual ~A()
{ cout<<"A free!"<<endl;}
protected:
int a;};
class B: public A {
public:
B(char *,int);
~B( ){
cout<<"B free!"<<endl; delete [ ]message;}
virtual void print( );
private:
char *message;
int len; };
B::B(char *s,int i):A(i) {
len=strlen(s)+1;
message=new char[len];
strcpy(message,s); }
void B::print( ) {
A::print( );
cout<<message<<endl; }
void main( )
{ A *pa=new B("this",10);
pa->print( );
delete pa; }