I'm getting like, 60 some errors and I don't know what I'm doing wrong. Everything seems to be assembled like my last assignment but it doesn't work this time. Any help on what I'm doing wrong would be appreciated.
Employee.h - #ifndef EMPLOYEE_H
-
#define EMPLOYEE_H
-
#include <string>
-
-
class Employee
-
{
-
private:
-
string first_name;
-
string last_name;
-
string employee_id;
-
public:
-
Employee();
-
Employee(string, string, string);
-
void set_first_name(string);
-
void set_last_name(string);
-
void set_employee_id(string);
-
string get_first_name();
-
string get_last_name();
-
string get_employee_id();
-
void display_e();
-
};
-
-
#endif
Employee.cpp - #include "Employee.h"
-
#include <string>
-
#include <iostream>
-
using namespace std;
-
-
Employee::Employee();
-
{ first_name = "unknown";
-
last_name = "unknown";
-
employee_id = "EEEEE"; }
-
-
Employee::Employee(string first_name, string last_name, string employee_id);
-
{ set_first_name(first_name);
-
set_last_name(last_name);
-
set_employee_id(employee_id); }
-
-
void Employee::set_first_name(string first);
-
{ first_name = first; }
-
-
void Employee::set_last_name(string last);
-
{ last_name = last; }
-
-
void Employee::set_employee_id(string id);
-
{ employee_id = id; }
-
-
string Employee::get_first_name();
-
{ return first_name; }
-
-
string Employee::get_last_name();
-
{ return last_name; }
-
-
string Employee::get_employee_id();
-
{ return employee_id; }
-
-
void Employee::display_e();
-
{ cout << "First name: " << first_name << endl;
-
cout << "Last name: " << last_name << endl;
-
cout << "Employee ID: " << employee_id << endl; }
Lab09.cpp - #include "Employee.h"
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
-
int main()
-
{
-
Employee emp("John", "Doe", "E1234");
-
emp.display_e();
-
-
return 0;
-
}
6 5461 gpraghuram 1,275
Recognized Expert Top Contributor
I saw one problem....
using namespace std; is missing in the employee.h file.
i will post again if i find other errors.
raghuram
Hmm, I didn't think you needed that in the header but it cut my errors from 60 some to 18.
Any idea what these mean? -
employee.cpp(6) : error C2761: '{ctor}' : member function redeclaration not allowed
-
employee.cpp(7) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(11) : error C2761: '{ctor}' : member function redeclaration not allowed
-
employee.cpp(12) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(16) : error C2761: 'void Employee::set_first_name(std::string)' : member function redeclaration not allowed
-
employee.cpp(17) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(19) : error C2761: 'void Employee::set_last_name(std::string)' : member function redeclaration not allowed
-
employee.cpp(20) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(22) : error C2761: 'void Employee::set_employee_id(std::string)' : member function redeclaration not allowed
-
employee.cpp(23) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(25) : error C2761: 'std::string Employee::get_first_name(void)' : member function redeclaration not allowed
-
employee.cpp(26) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(28) : error C2761: 'std::string Employee::get_last_name(void)' : member function redeclaration not allowed
-
employee.cpp(29) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(31) : error C2761: 'std::string Employee::get_employee_id(void)' : member function redeclaration not allowed
-
employee.cpp(32) : error C2447: '{' : missing function header (old-style formal list?)
-
employee.cpp(34) : error C2761: 'void Employee::display_e(void)' : member function redeclaration not allowed
-
employee.cpp(35) : error C2447: '{' : missing function header (old-style formal list?)
gpraghuram 1,275
Recognized Expert Top Contributor
The issue is in the Employee.cpp file is the ; at the end of every function.
I have corrected it...echeck it -
#include "Employee.h"
-
#include <string>
-
#include <iostream>
-
using namespace std;
-
-
Employee::Employee()
-
{ first_name = "unknown";
-
last_name = "unknown";
-
employee_id = "EEEEE"; }
-
-
Employee::Employee(string first_name, string last_name, string employee_id)
-
{ set_first_name(first_name);
-
set_last_name(last_name);
-
set_employee_id(employee_id); }
-
-
void Employee::set_first_name(string first)
-
{ first_name = first; }
-
-
void Employee::set_last_name(string last)
-
{ last_name = last; }
-
-
void Employee::set_employee_id(string id)
-
{ employee_id = id; }
-
-
string Employee::get_first_name()
-
{ return first_name; }
-
-
string Employee::get_last_name()
-
{ return last_name; }
-
-
string Employee::get_employee_id()
-
{ return employee_id; }
-
-
void Employee::display_e() //dont add a ; here
-
{ cout << "First name: " << first_name << endl;
-
cout << "Last name: " << last_name << endl;
-
cout << "Employee ID: " << employee_id << endl; }
-
-
Raghuram
Thank you so much. That fixed all the errors. Now I can move on and code the rest of the program.
Alright, I'm trying to add in a child class and I'm sure that the errors I'm getting have to do with me not calling the variables right or something. It started out at 15 errors and I've got it down to 6 and now I'm stuck.
Employee.h - #ifndef EMPLOYEE_H
-
#define EMPLOYEE_H
-
#include <string>
-
using namespace std;
-
-
class Employee
-
{
-
private:
-
string first_name;
-
string last_name;
-
string employee_id;
-
public:
-
Employee();
-
Employee(string, string, string);
-
void set_first_name(string);
-
void set_last_name(string);
-
void set_employee_id(string);
-
string get_first_name();
-
string get_last_name();
-
string get_employee_id();
-
void display_e();
-
};
-
-
class StaffEmployee:public Employee
-
{
-
private:
-
int annual_salary;
-
bool outsourced;
-
int tax_bracket;
-
public:
-
StaffEmployee();
-
StaffEmployee(string, string, string, int, bool, int);
-
void set_annual_salary(int);
-
void set_outsourced(bool);
-
void set_tax_bracket(int);
-
void display_s();
-
};
-
-
#endif
Employee.cpp - #include "Employee.h"
-
#include <string>
-
#include <iostream>
-
using namespace std;
-
-
Employee::Employee()
-
{ first_name = "unknown";
-
last_name = "unknown";
-
employee_id = "EEEEE"; }
-
-
Employee::Employee(string first_name, string last_name, string employee_id)
-
{ set_first_name(first_name);
-
set_last_name(last_name);
-
set_employee_id(employee_id); }
-
-
void Employee::set_first_name(string first)
-
{ first_name = first; }
-
-
void Employee::set_last_name(string last)
-
{ last_name = last; }
-
-
void Employee::set_employee_id(string id)
-
{ employee_id = id; }
-
-
string Employee::get_first_name()
-
{ return first_name; }
-
-
string Employee::get_last_name()
-
{ return last_name; }
-
-
string Employee::get_employee_id()
-
{ return employee_id; }
-
-
void Employee::display_e()
-
{ cout << "First name: " << first_name << endl;
-
cout << "Last name: " << last_name << endl;
-
cout << "Employee ID: " << employee_id << endl; }
-
-
StaffEmployee::StaffEmployee()
-
{ annual_salary = 0;
-
outsourced = false;
-
tax_bracket = 1; }
-
-
StaffEmployee::StaffEmployee(string first_name, string last_name, string employee_id, int annual_salary; bool outsourced, int tax_bracket)
-
{ set_first_name(first_name);
-
set_last_name(last_name);
-
set_employee_id(employee_id);
-
set_annual_salary(annual_salary);
-
set_outsourced(outsourced);
-
set_tax_bracket(tax_bracket); }
-
-
void StaffEmployee::set_annual_salary(int annual)
-
{ annual_salary = annual; }
-
-
void StaffEmployee::set_outsourced(bool out)
-
{ outsourced = out; }
-
-
void StaffEmployee::set_tax_bracket(int tax)
-
{ tax_bracket = tax; }
-
-
void StaffEmployee::display_s()
-
{ cout << "First name: " << get_first_name() << endl;
-
cout << "Last name: " << get_last_name() << endl;
-
cout << "Employee ID: " << get_employee_id() << endl;
-
cout << "Annual salary: " << annual_salary << endl;
-
cout << "Outsourced: " << outsourced << endl;
-
cout << "Tax bracket: " << tax_bracket << endl; }
Lab09.cpp - #include "Employee.h"
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
-
int main()
-
{
-
Employee emp("John", "Doe", "E1234");
-
emp.display_e();
-
-
StaffEmployee staff("Natalie", "Simons", "E3345", 56000, true, 3);
-
staff.display_s();
-
-
return 0;
-
}
- employee.cpp(44) : error C2143: syntax error : missing ')' before ';'
-
employee.cpp(44) : error C2761: '{ctor}' : member function redeclaration not allowed
-
employee.cpp(44) : error C2062: type 'int' unexpected
-
employee.cpp(44) : error C2059: syntax error : ')'
-
employee.cpp(45) : error C2143: syntax error : missing ';' before '{'
-
employee.cpp(45) : error C2447: '{' : missing function header (old-style formal list?)
oler1s 671
Recognized Expert Contributor
Why were you stuck? If you look at the errors, it looks like there is a problem around line 44. So you start reading a couple of lines back (line 42, say), and look closely for syntax errors. Things like a missing semicolon, misplaced brace, etc.
I found that you had a semicolon after int annual_salary, when it should be a comma.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: chat |
last post by:
Hi, every body.
I have 3 files like this:
--------------------------------------------------------
file name : header.h
#ifndef TEST_H
#define TEST_H
int a=1;
double b=0.5;
|
by: srikar |
last post by:
Hi all,
I am working on porting of code in C++, I am having the following problem.
In my code The following structure has been defined
static struct rwtable { /* reserved word table */...
|
by: The Cool Giraffe |
last post by:
Please note that i do intend to use a header file. However,
i'm not sure if it's really needed or just a convention.
Suppose we have the following two files.
// Something.h
class Something {...
|
by: Jess |
last post by:
Hello,
I was told that if I have a template class or template function, then
the definitions must be put into the header file where I put the
declarations. On the other hand, it is generally...
| |
by: Swapnil Kale |
last post by:
Hi,
I'm working on a Migration project (Forte to JAVA).
The forte client had a C++ dll which used to call one more FORTE dll
for a complex database calculations.
Now all the forte code has...
|
by: araman |
last post by:
I have a header file that gets included with my main pages. I moved a file to a different folder that has the header.asp fie in it but when I go to that page the header does not get included.It works...
|
by: quophyie |
last post by:
Hi guys
I''m a new C++ programmer and I am having a few problems with some structs that I have defined in my header file and want to use in my CPP file. The struct called "deck" is defined in a...
|
by: nguillot |
last post by:
Hello.
If I have the following classes:
class B {};
typedef B tB;
if A is:
class A
|
by: adikat |
last post by:
I am trying to set up a webpage where a user can download a .PNG image. The download works fine via computer and browser but it doesn't work when I try to download it via a browser on my Android...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |