
Originally Posted by
why06
Functions receive arguments. Those arguments are called parameter. Functions are one of the major points of programming. writefloat() would no doubt write to the address specified in its parameters and change it to zero in this case.
Yeah but if that was so, it would be more like this
Code:
writefloat(adr_speed, 0);
It would have 2 arguments. Functions either return nothing or return some kind of value, assuming it returns a value, this value would not be stored anywhere as of yet, thus how could you assign another value to it. Infact even if this does work would be lost and irretrievable. Actually furthermore it makes even less sense cause i just remembered that you can't assign a value to a value (i.e. 3 = 4; ).
But then again adr_speed is an address so it wouldn't really matter if it was irretrievable so then in that case wouldn't it be more like
Code:
writefloat(*adr_speed) = 0;
But upon reflection this couldn't be correct either because the value returned by a function is just a copy not the actual value itself, and also the fact you can't assign a value(numeric constant i think) to another (numeric constant?) which brings me back to this not making sense v_v
As a side note i tried an example of this just to make sure.
Code:
#include <iostream>
using namespace std;
int blah(int x);
int main(){
int x = 3;
blah(x)=0;
cin.get();
cin.get();
return 0;
}
int blah(int x){
return x;
}
If one tries to compile this they get the error:
Error 1 error C2106: '=' : left operand must be l-value c:\users\jon\desktop\c++\c++ ranprojs\testing grounds console\whileloop test.cpp 195