S
strongburn
Unregistered / Unconfirmed
GUEST, unregistred user!
#inlcude "stdafx.h"
class B{
char c;
public:
B( char n):c {}
virtual void X(void) {printf("%c",c);}
void Y(void) {printf("%c",c-1);}
virtual ~B(void) {X();Y():}
};
class Dublic B{
char c;
public:
D(char n):B(n+1),c {}
void X(void) {printf("%c",c);}
virtual void Y(void) {printf("%c",c-1);}
~D(void){X();Y();}
};
B *newB(char c)
{
return new D(c);
}
int main(int argc, char* argv[])
{
B *pb= newB('X');
pb->X();
pb->Y();
delete pb;
return 0;
}
分析程序运行的过程及结果!
class B{
char c;
public:
B( char n):c {}
virtual void X(void) {printf("%c",c);}
void Y(void) {printf("%c",c-1);}
virtual ~B(void) {X();Y():}
};
class Dublic B{
char c;
public:
D(char n):B(n+1),c {}
void X(void) {printf("%c",c);}
virtual void Y(void) {printf("%c",c-1);}
~D(void){X();Y();}
};
B *newB(char c)
{
return new D(c);
}
int main(int argc, char* argv[])
{
B *pb= newB('X');
pb->X();
pb->Y();
delete pb;
return 0;
}
分析程序运行的过程及结果!