D
D
Daniil Demidko2016-04-27 11:02:36
C++ / C#
Daniil Demidko, 2016-04-27 11:02:36

Order of initialization?

Here is the class:

class Exper 
{
private:
    int Number = 475;
public:
    Exper(const int & num): Number(num) 
    {
    }
};

What value will be assigned to the Number field first? num or 475?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AtomKrieg, 2016-04-27
@Daniro_San

en.cppreference.com/w/cpp/language/initializer_list

struct S {
    int n = 42;
    S() : n(7) {} // will set n to 7, not 42
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question