Solved

error message

Posted on 2000-03-14
12
366 Views
Last Modified: 2010-04-10
good morning,
i'm getting an error message and I was wondering if anyone knew what this means.

error C2297: '*' : illegal, right operand has type 'float (__cdecl *)(float)'
 
here is the line it says the error is on:

return input * totalDeduction;

here is the complete function :
float totalDeduction(float input)
{
double deduction = 0.425;
return input * totalDeduction;
} //end of calcDeductions function

0
Comment
Question by:nationnon
  • 8
  • 4
12 Comments
 
LVL 1

Author Comment

by:nationnon
ID: 2616439
: warning C4305: 'initializing' : truncation from 'const double' to 'float'

is the warning message when I change double deduction into float deduction.

but i'm not so worried about that.
0
 
LVL 7

Accepted Solution

by:
KangaRoo earned 35 total points
ID: 2616448
You are trying to multiply the float 'input'ith the function pointer 'totalDeduction'. Maybe you wanted this:

float totalDeduction(float input)
                  {
                  double deduction = 0.425;
                  return input * deduction;
                  } //end of calcDeductions function
0
 
LVL 1

Author Comment

by:nationnon
ID: 2616520
Adjusted points from 10 to 15
0
 
LVL 1

Author Comment

by:nationnon
ID: 2616521
now it's a warning message stating that
: warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data

the line it's on is
return input * deduction;



0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2616546
That's correct, the function returns a float. It calculates with doubles however, because deduction is declared as a double. two solutions:

float totalDeduction(float input)
{
     float deduction = 0.425;
     return input * deduction;
}

// Or:

double totalDeduction(double input)
{
     double deduction = 0.425;
     return input * deduction;
}
0
 
LVL 1

Author Comment

by:nationnon
ID: 2616817
Adjusted points from 15 to 25
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:nationnon
ID: 2616818

I have one last warning and it is warning C4700: local variable 'deduction' used without having been initialized

If i'm not mistaken the variable has been initialized.  Do I have to go add (float) deduction 0.0; after the normal float deduction; , will that fix it? and what will it do if it does fix it?


0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2618945
Huh? how can that be???
Can you paste the code, or which of the above did you use?
0
 
LVL 1

Author Comment

by:nationnon
ID: 2620753
the  double totalDeduction(double input)
{
     double deduction = 0.425;
     return input * deduction;
}

got rid of one warning.

but there are two warnings
: warning C4700: local variable 'deduction' used without having been initialized

warning C4700: local variable 'grossIncome' used without having been initialized





0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2635297
In the totalDeduction function 'deduction' is initialized in the very first line. I haven't seen 'grossIncome' before. Check the line numbers the compiler gives with the warnings, I suspect they refer to another function.
0
 
LVL 1

Author Comment

by:nationnon
ID: 2635626
Adjusted points from 25 to 35
0
 
LVL 1

Author Comment

by:nationnon
ID: 2635627
I figured it out.  I had to define the variables which was very simple. totalDeductions = .45;
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now