Виртуальный конструктор
От: dipso  
Дата: 24.03.14 00:54
Оценка: :)))
Летать летает.
#include <windows.h>
#include <tchar.h>
#include <string>
#include <iostream>


struct First;

struct VCons
{

    First* first;

    VCons()
    {}

    ~VCons();
};


struct First
{
    First(VCons& vc=VCons())
    {
        vc.first = this;
    }

    virtual void Print()
    {
        std::cout<<"in First"<<std::endl;
    }

    void Init()
    {
        Print();
    }
};

struct Second : public First
{
    Second(VCons& vc=VCons()) : First(vc)
    {}

    void Print()
    {
        std::cout<<"in Second"<<std::endl;
    }
};

struct Third : public Second
{
    Third(VCons& vc=VCons()) : Second(vc)
    {}

    void Print()
    {
        std::cout<<"in Third"<<std::endl;
    }
};

VCons::~VCons()
{

    first->Print();
}

int main()
{
    Third s;

    int i=0;
    std::cin>>i;
    return 0;
}

пойдёт?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.