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 5469 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. It is
almost like it is trying to implement it's own COM interfaces...
below is the header, and a link to the dll+code:
Zip file with header, example, and DLL:...
|
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 */
char * rw_name; /* representation */
int rw_yylex; /* yylex() value */
} rwtable = { /* sorted */
# include "y_token_names.h"
|
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 {
private: int number;
public:
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 good to put source
code and declaration into separate files (.h head filer and .cpp
source file). What can I do to template functions/classes? Do I have
to put them all into one header file?
Thanks,
| |
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 been migrated to JAVA except this piece of
code where C++ dll calls Forte DLL.
|
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 in its original folder so the code on the page is correct. Am I missing something?
|
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 file called "Cards.h". In the corresponding CPP file called "Cards.cpp" when I try to use the struct "deck", I get a lot of errors from the compiler as displayed in my compiler errors below. I have tried all manner of things including defing variables...
|
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 phone. It tries to download but then give me 'download unsuccessful' it doesn't give any other errors.
Here is the PHP code that I am using:
header('Content-Description: File Transfer');
header('Content-Type: image/png');...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |