The : in function definitions?

Feb 7, 2019 at 8:52am

1
2
3
int addTwoNum(int a, int b) : (bunch of crap goes here) {
 return (a+b);
}


What is it called so I can look up information about it? I tried looking up basic function information, but nothing I saw covered it, but I know I've seen it before.
Feb 7, 2019 at 8:55am
This is [would be] an initialiser list [for a class or struct constructor] : https://en.cppreference.com/w/cpp/utility/initializer_list
Last edited on Feb 7, 2019 at 10:02am
Feb 7, 2019 at 9:56am
It looks like a member initializer list (not to be confused with std::initializer_list) but those are only allowed on constructors, not on regular functions.
Feb 7, 2019 at 10:00am
Oh yes my bad, should have specified that they are not allowed for functions..
Feb 7, 2019 at 11:37am
Thank you for the quick replies. I will look into it. Thanks.
Topic archived. No new replies allowed.