I am in first year in BSc Computer Science. I received a comment from my Professor on my recently submitted assignment . I initialized an int variable to zero : int count{0};
. The book assigned to us in the course gives only one way to initialize a variable by using an assignment statement.
int count = 0;
I don't remember where I learnt the curly braces method to initialize the variable. According to my professor , this is not a legal way to do it. My program runs without any errors in Atom and also on online debugger. I always check my program for errors from two different platforms. So, I am confused whether my method was wrong and was missed by the compiler or this method is legal but not considered standard.
Any clarification will be helpful. Also any advice on good programming practices for debugging, so it doesn't happen again as I lost 4 marks from a 10 mark assignment.