I went to the university and tried to get a hold of the professor ( who is actually a doctor of computer science who runs the who computer science department) but couldnt get a hold of him because he had left all ready.
But i did talk to a computer science teacher
she said that
references are "passed by reference" and that pointers are data types.
she explained to me how references work
double void test(int& x)<-- decloration before int main
at this point the variable x has been declared and that means that variable x takes up a certain memory spot that is a double.........lets say that it takes up memory spot number 1101
after int main you declare other variables that will be used by the test function
then you put down a function call,(the function call is all ways on the right hand side of the = sign)
bill = double void test (int& x)
so at this point the memory for variable is still at memory location 1101
the function call goes down to the function body and then returns back to the function call that gives out a total which is where the word bill is at.
so now the program goes on
now comes another function cal but instead of it being variable x, you change it to variable w, which was delcared right after the int main()
so now the function call looks like this
double void test(int& w)
the thing here is that w doesnt take the memory space of 1101, it takes the memory space of 1120
the teacher told me that the memory location at 1101 , which is variable x , is pointing at the memory location for variable w, which is at memory location 1120
its simular to pointers , except that its not
as the program continues to go on another function call will come up
instead of it being x or w, it will be a.
double void test (int& a);
variable a will have its own memory place, lets just say that variable a will take memory spot 1130
now heres the thing
when the variable changes from x to w then that means that x ispointing to w and when the variable changes from w to bing a , that means that x will stop pointing to w and then point to a.
she also told me that what ever the varaible that comes up in the parameter ( w, a, ect) that it will always be pointed to by x and that what ever variable it was pointing will stop pointing to that variable. each variable ( w,a, ect) that is declared will have its own memory spot ( w=1120, a=1130)
so this means that i can change the name of the variables.......from x to a or be or what ever as many times as i want as long as i declare them. This means that this kind of process can be infinate.....not that it actually would be.
I asked her about incrementing and decrementing pointers and functions
she didnt say anything about incrementing and decrementing pointers but she did say that you can increment and decrement functions
heres how she explained it:
double void test (int& x)
this means that x is in memory space 1101.
lets say you put a value on varible x and say that its 2.00
so this would mean that 2.00 would be in memory space 1101 and that memory space 1101 is the variable int& x
she said you can create a formulat like this
x = x + 1
if this formula was applied to the program then that menas that the 2.00 would change to 3.00
so incrementing and decrementing of values in variables of refernce parameters can be done.
I dont know anything about pointers so i cant say anything about them and she didnt say anything about them. Pointers will come in time for me
passed by reference and pointers are a data type.