Default initialization of C++ Member arrays?

前端 未结 3 797
萌比男神i
萌比男神i 2020-12-15 18:21

This is a simple question, but I can\'t seem to find a definitive answer.

If we have the following class:

class Test
{
...
  char testArray[10];

...         


        
3条回答
  •  一生所求
    2020-12-15 18:45

    I believe that if you don't initialize it when you declare it, it can be set to anything. Sometimes it is an address or random looking value.

    Best practice is to initialize after declaring.

提交回复
热议问题