I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
{
fGoo = magoo;
}
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
I see some code in a codebase I'm working on that looks like:
ZfooName::ZfooName(int magoo)
: ZfooName()
{
fGoo = magoo;
}
I'm assuming this is a C++11 feature, since it breaks in VS2012, but what does it mean?
This is a new feature in C++11. It's called a delegating constructor.
The constructor calls the default constructor first (the constructor that is being delegated to). After the default constructor returns, the body of the delegating constructor is executed.
See http://www.stroustrup.com/C++11FAQ.html#delegating-ctor and https://en.cppreference.com/w/cpp/language/initializer_list#Delegating_constructor for additional information.