Solved

token error

Posted on 2000-04-20
6
298 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
Arduino EDI - Programming language 3 80
Least Squares Curve Fitting 4 61
Error creating a new C++ project in ,net 20 21
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. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

911 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

22 Experts available now in Live!

Get 1:1 Help Now