|
|
|
|
anonymous@anonymous:~/sandbox$ g++ employee.cxx -o employee.exe employee.hpp:4: error: new types may not be defined in a return type employee.hpp:4: note: (perhaps a semicolon is missing after the definition of ‘Employee’) employee.cxx:2: error: two or more data types in declaration of ‘main’ anonymous@anonymous:~/sandbox$ |
|
|
|
|
employee::~employee() { }
. But you don't need a dtor for this class if it's empty. You can leave that whole thing out.
|
|
|
|
anonymous@anonymous:~/sandbox$ g++ employee.cxx -o employee.exe In file included from employee.cxx:1: employee.hpp:6: error: ISO C++ forbids declaration of ‘employee’ with no type employee.hpp:7: error: expected class-name before ‘(’ token employee.cxx:2: error: ‘employee’ has not been declared employee.cxx:2: error: ISO C++ forbids declaration of ‘employee’ with no type employee.cxx: In function ‘int employee(int, int, int)’: employee.cxx:3: error: ‘itsAge’ was not declared in this scope employee.cxx:4: error: ‘itsYearsOfService’ was not declared in this scope employee.cxx:5: error: ‘itsSalary’ was not declared in this scope employee.cxx: At global scope: employee.cxx:7: error: expected constructor, destructor, or type conversion before ‘::’ token employee.cxx: In function ‘int main()’: employee.cxx:11: error: no matching function for call to ‘Employee::Employee(int, int, int)’ employee.hpp:4: note: candidates are: Employee::Employee() employee.hpp:4: note: Employee::Employee(const Employee&) employee.cxx:17: error: ISO C++ forbids comparison between pointer and integer employee.cxx:17: error: ISO C++ forbids comparison between pointer and integer employee.cxx:27: error: ISO C++ forbids comparison between pointer and integer employee.cxx:27: error: ISO C++ forbids comparison between pointer and integer anonymous@anonymous:~/sandbox$ |
Employee
and sometimes you have employee
. Either capitalize it or don't -- remember that C++ is case sensitive, so you need to pick one and use it everywhere. employee(); // in your header it takes no parameters
|
|
|
|
|
|
|
|
anonymous@anonymous:~/sandbox$ g++ employee.cxx -o employee.exe employee.cxx: In function ‘int main()’: employee.cxx:17: error: ISO C++ forbids comparison between pointer and integer employee.cxx:17: error: ISO C++ forbids comparison between pointer and integer employee.cxx:28: error: ISO C++ forbids comparison between pointer and integer employee.cxx:28: error: ISO C++ forbids comparison between pointer and integer |
char input;
,'y'
) is char."y"
) is a string.input
is ALSO used as an integer in your code (for the age, salary, etc). So you'll probably need to have two variables for input. One which is a string/char, and another which is an integer.
input
storing an integer, I already declared a separate variable. I added a few lines of code to print the results, to ensure it worked. In case you're interested, here's the final code:
|
|
|
|
anonymous@anonymous:~/sandbox$ g++ employee.cxx -o employee.exe anonymous@anonymous:~/sandbox$ ./employee.exe John is 35 years old. John has 10 years of service. John earns $60000 a year. Would you like to change these values (enter y or n)? y Enter John's age: 40 Enter John's years of service: 15 Enter John's annual salary: 100000 Values changed. John is 40 years old. John has 15 years of service. John earns $100000 a year. |