[edited] what does ':' do in following statement ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

14th May 2021, 4:49 PM
𝖆𝖙.𝖚𝕷
𝖆𝖙.𝖚𝕷 - avatar
4 Answers
+ 1
Where is the code?
14th May 2021, 5:02 PM
Atul [Inactive]
0
It's member initializer. It's used to initialize the class members. https://www.sololearn.com/learn/CPlusPlus/1896/
14th May 2021, 5:35 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
I know , but I am taking about ':' after initializer
14th May 2021, 6:22 PM
𝖆𝖙.𝖚𝕷
𝖆𝖙.𝖚𝕷 - avatar
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) {}
15th May 2021, 3:30 AM
你知道規則,我也是
你知道規則,我也是 - avatar