Where do you need to add the conversion function operator int () const so that the code below compiles?
struct B
    B() { }
    virtual const B * f() const { return this; }
    virtual  ~B() { }

struct D1 : public B
    D1() : B() { }
    const D1 * f() const { return this; }
    ~D1() { }

int main()
    const B * const b = new D1;
    const int i = * b->f();
    return 0;
Into the structure 'B'. The value of a function call is the value returned by the called function except in a virtual function call if the return type of the final overrider is different from the return type of the statically chosen function, the value returned from the final overrider is converted to the return type of the statically chosen function. Standard 0x version

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Зарегистрируйся сейчас
или Подпишись на будущие тесты