i want to know how to return more than one variable from a function..considering the two variables are totally different say a char and a float
Change global variables.
.
Use a structure:
struct ReturnData{
float floatVariable;
char charVariable;//Name these something that makes sense.
}
ReturnData myFunction(){
//Do some stuff
ReturnData temp;
temp.floatVariable=0;//some value
temp.charVariable='x';//some value
}
[code]
Google "call by reference" or "call by reference c++" or "c++ call by reference"
Using call by reference you pass parameters to the called function and if the called function modifies them, the values of the variables in the caller function will also be modified.
In c++ you simply insert a & before the variable name in the function declaration to indicate that the parameter is being called by reference instead of by value.
--- bill
Fuzzyzilla:
ReturnData myFunction(){
//Do some stuff
ReturnData temp;
temp.floatVariable=0;//some value
temp.charVariable='x';//some value
}
it is important to remember to actually, well, umm.. return!!!!