468,496 Members | 1,791 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

error C3861: 'xxxx': identifier not found

OK, I'm getting just this one error.

error C3861: 'upload_data': identifier not found

I have that function in the header file, why is it not seeing it? I can post code if needed.
Dec 1 '07 #1
3 20272
weaknessforcats
9,207 Expert Mod 8TB
Yes, the identifier not found means the compiler does not know about upload_data.

Check that everything is spelled correctly and that you are including the header file.

If that fails, then post your header file and the line of code where the error occurs.
Dec 1 '07 #2
I have called other functions from the header file, so I'm not sure why it doesn't like this one.

HourlyEmployee.h
Expand|Select|Wrap|Line Numbers
  1. #include "Employee.h"
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. #ifndef HOURLYEMPLOYEE_H
  8. #define HOURLYEMPLOYEE_H
  9.  
  10. class HourlyEmployee:public Employee
  11. {
  12.     private:
  13.         double hourly_wage;
  14.         double hours_worked;
  15.         string department_name;
  16.     public:
  17.         HourlyEmployee()
  18.         {
  19.             hourly_wage = 0;
  20.             hours_worked = 0;
  21.             department_name = "unknown";
  22.         }
  23.  
  24.         HourlyEmployee(double hwage, double hworked, string dname, string first, string last, string ID) : Employee(first, last, ID)
  25.         {
  26.             set_hourly_wage(hwage);
  27.             set_hours_worked(hworked);
  28.             set_department_name(dname);
  29.         }
  30.  
  31.         void set_hourly_wage(double hwage)
  32.         {
  33.             hourly_wage = hwage;
  34.         }
  35.  
  36.         void set_hours_worked(double hworked)
  37.         {
  38.             hours_worked = hworked;
  39.         }
  40.  
  41.         void set_department_name(string dname)
  42.         {
  43.             department_name = dname;
  44.         }
  45.  
  46.         double set_hourly_wage()
  47.         {
  48.             return hourly_wage;
  49.         }
  50.  
  51.         double set_hours_worked()
  52.         {
  53.             return hours_worked;
  54.         }
  55.  
  56.         string set_department_name()
  57.         {
  58.             return department_name;
  59.         }
  60.  
  61.         double compute_salary()
  62.         {
  63.             double pay;
  64.             pay = hourly_wage * hours_worked;
  65.             return pay;
  66.         }
  67.  
  68.         void display()
  69.         {
  70.             Employee::display();
  71.             cout << "Department name: " << department_name << endl;
  72.             cout << "2 weeks salary: $" << compute_salary() << endl;
  73.         }
  74.  
  75.         int upload_data(HourlyEmployee g[], int n)
  76.         {
  77.             int count = 0;
  78.             string first, last, id, dname;
  79.             double hworked, hwage;
  80.  
  81.             ifstream infile;
  82.             while(!infile.eof() && count<n)
  83.             {
  84.                 infile >> first >> last >> id >> hworked >> hwage >> dname;
  85.                 g[count].set_firstName(first);
  86.                 g[count].set_lastName(last);
  87.                 g[count].set_employeeID(id);
  88.                 g[count].set_hours_worked(hworked);
  89.                 g[count].set_hourly_wage(hwage);
  90.                 g[count].set_department_name(dname);
  91.                 count++;
  92.             }
  93.             return count;
  94.         }
  95. }
  96.  
  97. #endif
main.cpp
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include "StaffEmployee.h"
  3. #include "HourlyEmployee.h"
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. #define SIZE 20
  9.  
  10. int main()
  11. {
  12.     int count;
  13.  
  14.     HourlyEmployee fellow;
  15.     fellow.display();
  16.  
  17.     cout << "" << endl;
  18.  
  19.     HourlyEmployee person(10, 55, "electronics", "Alan", "Good", "E1234");
  20.     person.display();
  21.  
  22.     HourlyEmployee group[SIZE];
  23.  
  24.     count = upload_data(group, SIZE);
  25.  
  26.     return 0;
  27. }
Dec 1 '07 #3
weaknessforcats
9,207 Expert Mod 8TB
count = upload_data(group, SIZE);
upload_data is a member function. You can't just call it like this.
Dec 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.