+ 1
[edited] what does ':' do in following statement ?
What is the use of ':" in c++? Line no 4/5 See code below https://code.sololearn.com/c2AJkrtgP9W9/?ref=app Or auto msg : messages; //this line
4 Antworten
+ 1
Where is the code?
0
It's member initializer. It's used to initialize the class members. https://www.sololearn.com/learn/CPlusPlus/1896/
0
I know , but I am taking about ':' after initializer
0
That's the syntax of it. member(value)
Saying you have a class:
class A {
private:
int n;
};
You can initialize n in the constructor with:
A(int number): n(number) {}