progman
21st March 2011, 15:23
K, I can't wrap my head around why this error keeps popping up. I am writing a conversion program and thanks to some prior help, I am able to start calculating some values, but I've run into a bit of a snag. Examples below:
My defines:
#define ACRE_SQ_CHAIN 10;
#define ACRE_RODS 160;
#define ACRE_SQ_LINKS 10000;
#define ACRE_HECTARE 0.4047;
and the calculation routine - this works:
if(to == "Hectare")
{
cvrt = temp * ACRE_HECTARE;
answer.setNum(cvrt);
leAcreAns->setText(answer);
}
This doesn't work:
if(to == "Rods")
{
cvrt = temp / ACRE_SQ_CHAIN * ACRE_RODS;
answer.setNum(cvrt);
leAcreAns->setText(answer);
}
This is the section that is throwing the 'unary error'. If I change ACRE_RODS to the actual hard coded value, that is 160, error still occurs. Why is it that in some cases, it figures out I want to multiply the values, but in other cases, it thinks there is a unary * issue....
If you look at the first section where it have temp * ACRE_HECTARE, that works fine, but, if I reverse it, so that it reads, ACRE_HECTARE * temp, it also throws the unary* error? What am I not seeing??
Thanks!
My defines:
#define ACRE_SQ_CHAIN 10;
#define ACRE_RODS 160;
#define ACRE_SQ_LINKS 10000;
#define ACRE_HECTARE 0.4047;
and the calculation routine - this works:
if(to == "Hectare")
{
cvrt = temp * ACRE_HECTARE;
answer.setNum(cvrt);
leAcreAns->setText(answer);
}
This doesn't work:
if(to == "Rods")
{
cvrt = temp / ACRE_SQ_CHAIN * ACRE_RODS;
answer.setNum(cvrt);
leAcreAns->setText(answer);
}
This is the section that is throwing the 'unary error'. If I change ACRE_RODS to the actual hard coded value, that is 160, error still occurs. Why is it that in some cases, it figures out I want to multiply the values, but in other cases, it thinks there is a unary * issue....
If you look at the first section where it have temp * ACRE_HECTARE, that works fine, but, if I reverse it, so that it reads, ACRE_HECTARE * temp, it also throws the unary* error? What am I not seeing??
Thanks!