Solved

token error

Posted on 2000-04-20
6
296 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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

705 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

14 Experts available now in Live!

Get 1:1 Help Now