Solved

error message

Posted on 2000-03-14
12
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

688 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