What will be displayed in the terminal as a result of the following code execution:
#include <iostream>

using namespace std;

const float WEIGHT = 1.0;

class A {
    public:
        A();
        A(int initialCount);

        float mWeight;
        int mCount;
};

A::A(int initialCount) :
        mCount(initialCount),
        mWeight(mCount*WEIGHT)
{
}

int main()
{
    A objA(15);
    cout<<objA.mWeight<<endl;

    return 0;
}
Explanation
When using the list of initializers, members are initialized in the order fixed in the class declaration, and not in the order specified in the list of initializers.

Следи за CodeGalaxy

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

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