Default constructors variables.

Hi! Let's say I have a class that does not have a constructor. Does the compiler creates a default constructor that initialises my variables to 0 or just an empty constructor?

1
2
3
4
5
6
7
class Test
{    private:
       int x;
       int y;
    public:
       int z;
};


EDIT:
(a)
 
Test::Test (){};


OR
(b)
1
2
3
4
5
6
7
Test::Test ()
{
      int x = 0;
      int y = 0;
    public:
      int z = 0;
};

And is there anything wrong with my understanding here? Like the creation of (b)? By the way, can there be more than 1 constructor for each class? Lastly, does all default constructors take no arguments? Thanks!
Last edited on
In short: it is safer to assume that compiler generated constructor does not initialize variables of builtin types.
http://stackoverflow.com/questions/2417065/does-the-default-constructor-initialize-built-in-types
Topic archived. No new replies allowed.