?
Solved

token error

Posted on 2000-04-20
6
Medium Priority
?
304 Views
Last Modified: 2010-04-02
I'm assuming I know what I programmer defined function is .  

I get an error saying:

C2239: unexpected token '{' following declaration of 'deduction'
 
Here's my code
// Calculation function

double deduction
{

//variable definitions
      double sTaxAmt;
      double fTaxAmt;
      double mDedAmt;
      const double sTaxPct = .08;      
      const double fTaxPct = .32;
      const double miscPct = .20;
      deduction = (sTaxPct + fTaxPct + miscPct);

}//end calculation 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
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
proskig earned 160 total points
ID: 2734869

double deduction()!!!!
{

//variable definitions
double sTaxAmt;
double fTaxAmt;
double mDedAmt;
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct); !!!!!

}//end calculation function

It should help
0
 
LVL 1

Author Comment

by:nationnon
ID: 2734911
Adjusted points from 20 to 30
0
 
LVL 1

Author Comment

by:nationnon
ID: 2734912
what does this mean ???

error C2659: '=' : overloaded function as left operand

it points to this

deduction = (sTaxPct + fTaxPct + miscPct);






0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:proskig
ID: 2734983
deduction token is not the result of a function - it is a pointer to the function. So it cannot assign to function numeric value. My code (return ...) should do what you intended to do.
0
 
LVL 1

Author Comment

by:nationnon
ID: 2735025
Adjusted points from 30 to 40
0
 
LVL 1

Author Comment

by:nationnon
ID: 2735026
I got four more warnings #include <iostream.h>


void main ()

// Declare and define variables
{
char fEfirstName[10];
char fElastName[10];
char sEfirstName[10];
char sElastName[10];
double fEgPay;
double fEnPay;
double sEgPay;
double sEnPay;
double fErate;
double fEhrs;
double sErate;
double sEhrs;
double deduction;



//User entered information

      cout <<"Enter first employee's last name: ";
      cin >> fElastName;
      cout <<"Enter first employee's first name: ";
      cin >> fEfirstName;
      cout <<"Enter first employee's pay rate: ";
      cin >> fErate;
      cout <<"Enter first employee's hours: ";
      cin >> fEhrs;
      cout << "Enter second employee's last name: ";
      cin >> sElastName;
      cout << "Enter second employee's first name: ";
      cin >> sEfirstName;
      cout << "Enter second employee's hours: ";
      cin >> sEhrs;
      cout << "Enter second employee's rate: ";
      cin >> sErate;

// employee hours * rate & netpay deduction
fEgPay = fErate * fEhrs;
sEgPay = fErate * sEhrs;
fEnPay = sEgPay - deduction;
sEnPay = sEgPay - deduction;

// ask user which employee they want to view
int nEmployee;

do
{
  cout << "Choose Employee 1 or 2: ";
  cin >> nEmployee;
}
while(nEmployee<=1 || nEmployee>=2);

if (nEmployee<=1)
      cout << fEfirstName << " " << fElastName << "'s gross pay was " << fEgPay << " "<< "but after deductions the pay is now " << fEnPay << endl;

if (nEmployee>=2)
      cout << sEfirstName << " " << sElastName << "'s gross pay was " << sEgPay << " " << "but after deductions the pay is now " << sEnPay << endl;      

}

//Main calculations



//End of main function

// Calculation function

double deduction()                  
{

//variable definitions
double sTaxAmt;
double fTaxAmt;
double mDedAmt;
const double sTaxPct = .08;
const double fTaxPct = .32;
const double miscPct = .20;
return (sTaxPct + fTaxPct + miscPct);

}//end calculation function



0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

719 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