![]() |
Employee Class/Implementation help
:
#include <iostream.h>My class. ^ :
#include "employee.h"My implementation of the class. ^ As far as the test program is concerned, I can figure that out on my own. However, the overall goals are to make ways to set and retrieve certain fields, construct and destruct an object made from Employee and to calculate the pay while having the Employee object initialize as either E1 or E2. And just for kicks, =P, the program constructs, initializes and displays the objects, and calculates/displays the gross pay for the week for one employee. Basically, I've tried my best to do this but I've run into a plethora of syntax errors due to my lack of skills with C++. With that said, here's my error log: :
(4): error C2511: 'int Employee::SetHours(int)' : overloaded member function not found in 'Employee'Any help is greatly appreciated. (= |
Well, my compiler is being screwy, so i'll look at it more when i get that running again (damn you VS .NET!) but i noticed for your include your using iostream.h which is the old version, now use:
:
#include<iostream>Also, in your .cpp file, you didnt specify any return types, which is probably why your getting all those "overloaded function differs only by return type..." errors. for example: int Employee::GetHours() |
I dont have time to sit down and compile it but I notice that in your header file you have:
:
int SetHours();:
Employee::SetHours( int hours )Same with SetPayRate also, before Employee:: you should have the return type of the function too i.e. void Employee::SetHours( int hours ){ for name, in your while loop you just have name[i++], I assume you meant lastname[i++] That should take care of most of your errors, at least I think. Its 5:30am and ive been working all night, so I hope I'm not too wrong. Good luck! |
Welp, I'm back again. I've tried a few things and I've found myself even further back than when I started. If you could help, it'd be much appreciated. And yes, I'm thankful for the help I have received. Thanks, people. :D
Class: :
#include <iostream>Implementation: :
#include "employee.h"Error log: :
c:\Documents and Settings\nerdfiles\My Documents\Projects\C++\PayrollApplication\Employee.cpp(12): error C2248: 'Employee::hours' : cannot access private member declared in class 'Employee' |
lots of things are wrong here :/
:
ostream & operator <<( ostream & os, const Employee E2 & E2)you cant use the & symbol when declaring a function i dont think, you have to specifiy it as 2 seperate variables and declare then thus. In your header file you have specified payrate, hours etc as private but then in the class you are trying to access them directly, you will need to use the getter's and setter to access them. Still going through the file will report back other things. I looked into it, it is a mess i would think about re-reading up on this stuff you have a lot wrong and personally i cant fix it |
Well, now I think I've got the class and implementation down.
Class: :
#ifndef EMPLOYEE_HImplementation: :
#include "employee.h"Now I'm just having trouble with displaying my information through the test program. I virtually have nothing but ideas on how I'm supposed to get the information to display which is kind of apparent through my Display() function, lol. But I've grown sore of writing incorrect code that I'm for certain won't work. Here's what I have so far: :
#include "employee.h"Any help? :D |
| All times are GMT -5. The time now is 2:10 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC