Ok guys I need some help with this code. I'm suposed to run this problem with it:

  • Rewrite the program to include a static data member named numemps. This variable, which should be an integer, shoud act as a counter that is initialized to zero, and is incremented by the class constructor each time a new object is declared. Rewrite the static function disp() to display the value of this counter.
  • Revise the main() function call disp() after each Employee object is created.
  • Compile the program and correct any syntax errors that are identified.
  • Run the program and verify that it displays the value of the static variable after each object is created.

I ran and compiled and I'm getting this error:
no matching function for call to `Employee::disp()'

And I dont understand why. As you can tell I'm a new at this.

#include <iostream> 
using namespace std;

class Employee
  // data declaration section
    static double taxRate;
    int idNum;
    static int numemps;

  // method declarations
    Employee(int = 0);    // constructor
    void display();      // access function
    static void disp( int numemps );  // static function

// static member definition
double Employee::taxRate = 0.07;   // this defines taxRate

// implementation section

Employee::Employee(int num)
  idNum = num;

void Employee::display()
  cout << "Employee number " << idNum
       << " has a tax rate of " << taxRate << endl;

void Employee::disp( int numemps )
  cout << "The static tax rate is " << taxRate << endl;

int main()
  Employee::disp();   // call the static functions
  Employee emp1(11122), emp2(11133);

  system( "PAUSE" ); 
  return 0;
9 Years
Discussion Span
Last Post by WaltP
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.