0

ok, quick question for those who know the standard well. when is a variable (and array and class object) set to 0 by default (all elements, all members) in C++. i know that if it's global it should be (is it?). are there any other cases?

4
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by invinate
0

I don't know the standard well at all. But I'd say it was always a good idea to intialise your variables, where ever they may be.

0

ok, quick question for those who know the standard well. when is a variable (and array and class object) set to 0 by default (all elements, all members) in C++. i know that if it's global it should be (is it?). are there any other cases?

static also,
well u can use sometimes like, but i never found it a gud idea.

int i[100] = {0} ;

intializer list in a class also help to achive it.

0

Why not?

beacuse it does not works when int i[100] is a memeber of a class.
rest if it is not a member of a class performence wise it is a good thing to write it that way.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.