I have this code:
Kuvio::Kuvio(Piste& paikka, string& nimi) : paikka(paikka), nimi(nimi) {}
Do not care about the words. I'd like to know is that a function definition, a function call or what? I'm not familiar with C++.
I have this code:
Kuvio::Kuvio(Piste& paikka, string& nimi) : paikka(paikka), nimi(nimi) {}
Do not care about the words. I'd like to know is that a function definition, a function call or what? I'm not familiar with C++.
It's a definition of the constructor of class Kuvio
using an initialization list.
It's almost equivalent to:
Kuvio::Kuvio(Piste& paikka, string& nimi)
{
paikka = paikka;
nimi = nimi;
}
, which is redundant. In general however, the difference is that the members are not initialized two times, as it would happen with my snippet of code, but only once in the initialization list.
Function definition, constructor of class Kuvio
.
It's defining the constructor of class Kuvio. The part between :
and {}
is an initializer list - it takes paikka and nimi member variables and initializes them with the values of paikka and nimi parameters.