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
Зареєструйся Зараз
або Підпишись на майбутні тести