Skip to content

int i = 0; vs int i {0}; #18

Answered by Himanshu40
Himanshu40 asked this question in Q&A
Discussion options

You must be logged in to vote

int i = 0; is an old style of initializing variables in C and C++. From C++11 onwards, initialization and assignment are different terms. Initialization is more effective for class member variables.
Must read: https://www.learncpp.com/cpp-tutorial/variable-assignment-and-initialization/#:~:text=Variable%20assignment%20and%20initialization

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Himanshu40
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants