#include <iostream>
class Abstract
{
public:
virtual void pureVirt() = 0;
};
class Derived: public Abstract
{
int a;
public:
Derived(int x):a(x){}
virtual void pureVirt(){std::cout<<"in pureVirt: "<< a <<"\n";}
};
void func(Abstract ** b);
int main()
{
Abstract * array[3];
func(array);
array[0]->pureVirt();
array[1]->pureVirt();
array[2]->pureVirt();
std::getwchar();
return 0;
}
void func(Abstract** b)
{
b[0]= new Derived(0);
b[1]= new Derived(1);
b[2]= new Derived(2);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogCmNsYXNzIEFic3RyYWN0CnsKcHVibGljOgogIHZpcnR1YWwgdm9pZCBwdXJlVmlydCgpID0gMDsKfTsKCmNsYXNzIERlcml2ZWQ6IHB1YmxpYyBBYnN0cmFjdAp7CiAgICBpbnQgYTsKcHVibGljOgogICAgRGVyaXZlZChpbnQgeCk6YSh4KXt9CiAgICB2aXJ0dWFsIHZvaWQgcHVyZVZpcnQoKXtzdGQ6OmNvdXQ8PCJpbiBwdXJlVmlydDogIjw8IGEgPDwiXG4iO30KfTsKIAp2b2lkIGZ1bmMoQWJzdHJhY3QgKiogYik7CiAKaW50IG1haW4oKQp7CiAgICBBYnN0cmFjdCAqIGFycmF5WzNdOwogICAgCiAgICBmdW5jKGFycmF5KTsKICAgIAogICAgYXJyYXlbMF0tPnB1cmVWaXJ0KCk7CiAgICBhcnJheVsxXS0+cHVyZVZpcnQoKTsKICAgIGFycmF5WzJdLT5wdXJlVmlydCgpOwoJCglzdGQ6OmdldHdjaGFyKCk7CgkKICAgIHJldHVybiAwOwp9CiAKdm9pZCBmdW5jKEFic3RyYWN0KiogYikKewogICAgYlswXT0gbmV3IERlcml2ZWQoMCk7CiAgICBiWzFdPSBuZXcgRGVyaXZlZCgxKTsKICAgIGJbMl09IG5ldyBEZXJpdmVkKDIpOwp9