Solved

error message

Posted on 2000-03-14
12
385 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
Industry Leaders: 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel/Word Add-in in what language? 5 160
Writing a parser for java language 4 100
One named event, multiple event handlers 2 54
c++  placing data into a form and an editbox 5 47
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

739 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