Легенда:
новое сообщение
закрытая нитка
новое сообщение
в закрытой нитке
старое сообщение
|
- Напоминаю, что масса вопросов по функционированию форума снимается после прочтения его описания.
- Новичкам также крайне полезно ознакомиться с данным документом.
[C++ Bug] Bug report 25.07.01 14:44 Число просмотров: 831
Автор: Ван Мо Статус: Незарегистрированный пользователь
|
если тебе все равно какую х-ню отлаживать, займись вот этимЖ
#include <stdio.h>
void* operator new (size_t size, void *ptr)
{
return ptr;
}
class Alien
{
public:
virtual void PrintMsg() { printf("This function called from class Alien.\n"); }
};
class Parent
{
public:
virtual void PrintMsg() { printf("This function called from class Parent.\n"); }
};
class Child: public Parent
{
public:
virtual void PrintMsg() { printf("This function called from class Child.\n"); }
void Magic()
{
new (this) Alien;
printf("Leave Magic.\n");
}
};
int main()
{
Child child;
Child* pChild = &child;
Child& rChild = child;
child.PrintMsg();
pChild->PrintMsg();
rChild.PrintMsg();
printf("\n");
child.Magic();
printf("\n");
child.PrintMsg();
pChild->PrintMsg();
rChild.PrintMsg();
return 0;
}
----------------------------------------
This function called from class Child.
This function called from class Child.
This function called from class Child.
Leave Magic.
This function called from class Child.
This function called from class Alien.
This function called from class Alien.
---
(MSVC6)
|
|
|