1>------ Rebuild All started: Project: Payroll, Configuration: Debug Win32 ------ 1> Employee.cpp 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(16): error C2556: 'Date Date::operator ++(int)' : overloaded function differs only by return type from 'Date &Date::operator ++(int)' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(15) : see declaration of 'Date::operator ++' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(16): error C2040: 'Date::operator ++' : 'Date (int)' differs in levels of indirection from 'Date &(int)' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\employee.cpp(56): error C3861: 'getBirtDate': identifier not found 1> Date.cpp 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(16): error C2556: 'Date Date::operator ++(int)' : overloaded function differs only by return type from 'Date &Date::operator ++(int)' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(15) : see declaration of 'Date::operator ++' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(16): error C2040: 'Date::operator ++' : 'Date (int)' differs in levels of indirection from 'Date &(int)' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(24): error C2511: 'Date &Date::operator ++(void)' : overloaded member function not found in 'Date' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(8) : see declaration of 'Date' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(30): error C2556: 'Date Date::operator ++(int)' : overloaded function differs only by return type from 'Date &Date::operator ++(int)' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(15) : see declaration of 'Date::operator ++' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(30): error C2040: 'Date::operator ++' : 'Date (int)' differs in levels of indirection from 'Date &(int)' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(32): error C3861: 'helpIncrement': identifier not found 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(37): error C2146: syntax error : missing ';' before identifier 'Date' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(37): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(38): error C2556: 'Date &Date::operator +=(int)' : overloaded function differs only by return type from 'const Date &Date::operator +=(int)' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(17) : see declaration of 'Date::operator +=' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(38): error C2373: 'Date::operator +=' : redefinition; different type modifiers 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(17) : see declaration of 'Date::operator +=' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(40): error C3861: 'helpIncrement': identifier not found 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(66): error C2039: 'helpIncrement' : is not a member of 'Date' 1> c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.h(8) : see declaration of 'Date' 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(68): error C2065: 'day' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(68): error C3861: 'endOfMonth': identifier not found 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(69): error C2065: 'day' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(71): error C2065: 'month' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(73): error C2065: 'month' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(74): error C2065: 'day' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(78): error C2065: 'year' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(79): error C2065: 'month' : undeclared identifier 1>c:\users\zekk ragnos\documents\visual studio 2012\projects\payroll\payroll\date.cpp(80): error C2065: 'day' : undeclared identifier 1> Generating Code... ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Here is my Date.h.
#ifndef DATE_H
#define DATE_H
#include <iostream>
using std::ostream;
class Date
{
friend ostream &operator<<(ostream &, const Date &);
public:
Date(int m=1, int d=1, int y=1900);//default constructor
void setDate(int, int, int);//set month, day, year
Date &operator++(int);//increment operator
Date operator++(int);//increment operator
const Date &operator+=(int);//add days
bool leapYear(int) const;
bool endOfMonth(int)const;
int getMonth()const;
private:
int month;
int day;
int year;
static const int days[];//array of days per month
void helpIncement();
};
#endif
Here is my Date.cpp
#include <iostream>
#include "Date.h"
const int Date::days[]=
{0,31,28,31,30,31,30,31,31,30,31,30,31};
Date::Date(int m, int d, int y)
{
setDate(m,d,y);
}
void Date::setDate(int mm, int dd, int yy)
{
month = (mm>=1 && mm <= 12)? mm:1;
year = (yy >= 1900 && yy <= 2100) ? yy: 1900;
if (month ==2 && leapYear(year))
day = (dd>= 1 && dd<= 29) ? dd : 1;
else
day = (dd >= 1 && dd <= days[month] ) ? dd: 1;
}
Date &Date::operator++()
{
helpIncrement();
return *this;
}
Date Date::operator++(int)
{
Date temp = *this;//hold state of object
helpIncrement();
//return unincremented
return temp;
}
cont Date &Date::operator+=(int additionalDays)
{
for (int i=0; i < additionalDays; i++)
helpIncrement();
return *this;
}
bool Date::leapYear(int testYear)const
{
if ( testYear % 400 == 0 ||
(testYear % 100 != 0 && testYear % 4 == 0))
return true;
else
return false;
}
int Date::getMonth()const
{
return month;
}
bool Date::endOfMonth(int testDay) const
{
if(month == 2 && leapYear(year))
return testDay ==29;
else return testDay==days[month];
}
void Date::helpIncrement()
{
if (!endOfMonth ( day))
day++;
else
if (month <12)
{
month++;
day=1;
}
else
{
year++;
month=1;
day=1;
}
}
ostream &operator<<( ostream &output, const Date &d)
{
static char *monthName[13] = { "", "January", "February",
"March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"};
output << monthName[d.month]<< ' '<<d.day<<"."<<d.year;
return output;
}
Here is my Employee.h
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using std::string;
#include "Date.h"
class Employee
{
public:
Employee( const string &, const string &, const string &,
int, int, int);
void setFirstName( const string &);//set first name
string getFirstName()const;//return first name
void setLastName( const string &);//set last name
string getLastName()const;//return last name
void setSocialSecurityNumber(const string &);//set SSN
string getSocialSecurityNumber()const;//return SSN
void setBirthDate(int,int,int);//set birthday
Date getBirthDate()const;//return birthday
virtual double earnings() const = 0; //pure virtual
virtual void print() const; //virtual
private:
string firstName;
string lastName;
string socialSecurityNumber;
Date birthDate;//employee's birthday
};//end class Employee
#endif //EMPLOYEE_H
Here is my Employee.cpp
#include <iostream>
using std::cout;
#include "Employee.h"//Employee class definition
Employee::Employee(const string &first, const string &last,
const string &ssn, int month, int day, int year)
: firstName(first), lastName(last), socialSecurityNumber(ssn),
birthDate(month, day, year)
{
}
void Employee::setFirstName(const string &first)
{
firstName=first;
}
string Employee::getFirstName()const
{
return firstName;
}
void Employee::setLastName(const string &last)
{
lastName=last;
}
string Employee::getLastName() const
{
return lastName;
}
void Employee::setSocialSecurityNumber(const string &ssn)
{
socialSecurityNumber = ssn;
}
string Employee::getSocialSecurityNumber()const
{
return socialSecurityNumber;
}
void Employee::setBirthDate( int month, int day, int year)
{
birthDate.setDate(month, day, year);
}
Date Employee::getBirthDate()const
{
return birthDate;
}
void Employee::print()const
{
cout<<getFirstName()<<' '<<getLastName()
<<"\nbirthday:"<<getBirtDate()
<<"\nsocial security number:"<<getSocialSecurityNumber();
}

New Topic/Question
Reply



MultiQuote



|