If you do something like void test(int x = 1000), you give the parameter a default value, which it will get initialized to if you do not pass it.
This means, that you could have something like this:
int add( int x, int y = 1000 )
If you call add with two arguments ( add( number1, number2 ) ), it will use the two arguments passed in within the function, but if you only pass one argument, it will default initialize the second argument to 1000. add( number1 ) is perfectly valid here, it will use y initialized as 1000.
Since you pass a number to the function, it will use your number instead of the default initialization.
//why do I have to init. a random value into test() to get it working, why cant I use x?
C++ does not guarantee you default initialized variables, which means that if you do not give a variable a value, it will be "initialized" to whatever is at the stack when creating the variable, though i think most compilers default initialize them for you under the hood, but keep in mind that it's not a C++ standard and that C++ alone does not guarantee you default initialized variables.
Shouldn't the adress for y be the same as for x, since I'm just overwritting the a value in that specific address?
y holds an address as value, which is the address of x. A variable has an address, a value and a type. Your pointer is of type int pointer and has some address windows gives your variable at that point in time. The value of your pointer is the address ( the memory address windows gives your variable ) of the variable x. The address of y is different from the address of x, though the value of y is equal to the address of x.