Output
От: Аноним  
Дата: 03.07.08 19:12
Оценка: -1
Что распечатает следующий код:
#include "stdio.h"
#include "conio.h"

class A
{
public:
    A() {printf( "constructor A\n");}
    A(const A & obj){ printf("copy constructor A\n"); }
        ~A() { printf("destructor A\n"); }
    virtual ~A() { printf("destructor A\n"); }
    virtual void fun1() { printf("fun1 A\n"); }
    void fun2(A obj) { printf("fun2 A\n"); }
};
class B: virtual public A
{
public:
    B(){ printf("constructor B\n"); }
    ~B(){ printf("destructor B\n"); }

};
class C: virtual public A
{
public:
    C(){ printf("constructor C\n"); }
    ~C(){ printf("destructor C\n"); }
    void fun1() { printf("fun1 C\n"); }

};
class D :  public B,  public C
{
public:
        D(){ printf("constructor D\n"); }
        ~D(){ printf("destructor D\n"); }
        void fun1(){ printf("fun1 D\n"); }
        void fun2(){ printf("fun2 D\n"); }

};

void main()
{
A * ptr;
A one;
ptr = new D();
ptr ->fun1();
ptr ->fun2(one);
delete ptr;
getch();
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.