Форум: "Потрепаться";
Текущий архив: 2002.03.28;
Скачать: [xml.tar.bz2];
ВнизВопрос о распространнёности Delphi в мире. Найти похожие ветки
← →
VuDZ (2002-02-15 03:38) [66]продолжаем-с флейм:
class CBase
{
public:
virtual void Init(int n) = 0;
virtual ~CBase(){};
};
class CA : public CBase
{
void Init(int n)
{
printf("Class A - %i\n", n);
}
virtual ~CA(){};
};
class CB : public CBase{
void Init(int n)
{
printf("Class B - %i\n", n);
}
virtual ~CB(){};
};
CBase* create(void)
{
switch(rand()%2)
{
case 0: return new CA();
case 1: return new CB();
}
return NULL;
}
void Do(void){
CBase *ptr = create();
ptr->Init(rand());
}
void main()
{
Do();
Do();
Do();
Do();
Do();
Do();
Do();
getch();
}
для более сложных вариантов надо использовать нечто вроде CRuntimeClass, IsKindOf()
Страницы: 1 2 3 вся ветка
Форум: "Потрепаться";
Текущий архив: 2002.03.28;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.007 c