Solved

token error

Posted on 2000-04-20
6
302 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 40 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
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 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

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!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

734 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