Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ Project, need all the help i can get!
#23
Dudewitbow Wrote:have you tried just writing another fuction that has 4 parameters with the same name?(so 2 floodlights create 4 parameters) so that when a function recieves 4 parameters, it knows when to use the second function and not the first


e.g

Function1(parameter, parameter)
{
//do stuff here
}

Function1(parameter, parameter, parameter, parameter)
{
//do stuff here, longer than above
}


is legal syntax for a function.


ALTERNATIVELY(probably youll end up using this way)

use an if statement that checks to see if measurement 3 and 4 are NOT a sentinel value(e.g initialize the data to a sentinel value like -1)
e.g

if(measure3 != -1) distance(measure3, measure4);// if measure3 is NOT the sentinel value, do the calculation of distance for the other 2 values

of course you may need another variable to hold the second distance value to be used.

hm, i do like your first idea a lot! but, i think i can totally throw out the function with only two parameters since option's A and B both have 4 parameters(2 measurements for each floodlight). so ill have:


double Distance(double measurement_1, double measurement_2, double measurement_3, double_measurement_4)
{
//now what goes in here since ill have two distances? 1 for each floodlight.. before when I had only two parameters it was just
Code:
double distance;
    distance = sqrt(measurement_1*measurement_1+measurement_2*measurement_2);
    return distance;
}
Reply


Messages In This Thread
C++ Project, need all the help i can get! - by InvictHero - 2014-05-02, 02:06 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)