error LNK1561: entry point must be defined

error LNK1561: entry point must be defined - I have received this error after build solution on my program that I am trying to complete for my class on converting work hours to work days. Any suggestions of why I would get this error?

NumDays.h

// Specification file for the NumDays class
#ifndef NUMDAYS_H
#define NUMDAYS_H

#include <iostream>
using namespace std;

class NumDays; // Forward Declaration

ostream &operator << (ostream &, const NumDays &);
istream &operator >> (istream &, NumDays &);

class NumDays
{
private:
int days; // To hold a number of days
int hours; // To hold a number of hours
void simplify(); // Defined in NumDays.cpp
public:
// Constructor
NumDays(int f = 0, int i = 0)
{
days = f;
hours = i;
simplify();
}

// Copy constructor
NumDays(NumDays &right)
{
days = right.days;
hours = right.hours;
}

// Mutator functions
void setdays(int f)
{
days = f;
}

void sethours(int i)
{
hours = i;
simplify();
}

NumDays multiply(NumDays obj)
{
NumDays temp;
temp.days = days * obj.days;
temp.hours = hours * obj.hours;
temp.simplify();
return temp;
}

int getdays() const
{
return days;
return 0;
}

int gethours() const
{
return hours;
return 0;
}

NumDays operator + (const NumDays &);
NumDays operator - (const NumDays &);
NumDays operator ++ (); // Prefix ++
NumDays operator ++ (int); // Postfix ++
bool operator > (const NumDays &);
bool operator < (const NumDays &);
bool operator == (const NumDays &);

bool operator >= (const NumDays &);
bool operator <= (const NumDays &);
bool operator != (const NumDays &);

operator double();
operator int();

friend ostream &operator << (ostream &, const NumDays &);
friend istream &operator >> (istream &, NumDays &);
};
#endif

NumDays.cpp

// Implementation file for the NumDays class
#include <cstdlib> // Needed for abs()
#include "NumDays.h"

//*****************************************************************
// Definition of member function simplify. This function *
// checks for values in the hours member greater than *
// eight or less than zero. If such a value is found, *
// the numbers in days and hours are adjusted to conform *
// to a standard worked days & hours expression. For example, *
// 8 hours would be converted to 1 day, 12 hours would be *
// converted to 1.5 days and 18 hours converted to 2.25 days. *
//*****************************************************************

void NumDays::simplify()
{
if (hours >= 8)
{
days += (hours / 8);
hours = hours % 8;
}
else if (hours < 0)
{
days -= ((abs(hours) / 8) + 1);
hours = 8 - (abs(hours) % 8);
}

}

NumDays NumDays::operator + (const NumDays &right)
{
NumDays temp;

temp.hours = hours + right.hours;
temp.days = days + right.days;
temp.simplify();
return temp;
}

NumDays NumDays::operator - (const NumDays &right)
{
NumDays temp;

temp.hours = hours - right.hours;
temp.days = days - right.days;
temp.simplify();
return temp;
}

NumDays NumDays::operator ++ ()
{
++hours;
simplify();
return *this;
}

NumDays NumDays::operator ++ (int)
{
NumDays temp(days, hours);

hours++;
simplify();
return temp;
}

bool NumDays::operator > (const NumDays &right)
{
bool status;

if (days > right.days)
status = true;
else if (days == right.days && hours > right.hours)
status = true;
else
status = false;

return status;
}

bool NumDays::operator < (const NumDays &right)
{
bool status;

if (days < right.days)
status = true;
else if (days == right.days && hours < right.hours)
status = true;
else
status = false;

return status;
}

bool NumDays::operator == (const NumDays &right)
{
bool status;

if (days == right.days && hours == right.hours)
status = true;
else
status = false;

return status;
}

ostream &operator<<(ostream &strm, const NumDays &obj)
{
strm << obj.days << " days, " << obj.hours << " hours";
return strm;
}

istream &operator >> (istream &strm, NumDays &obj)
{
// Prompt the user for the days.
cout << "days: ";
strm >> obj.days;

// Prompt the user for the hours.
cout << "hours: ";
strm >> obj.hours;

// Normalize the values.
obj.simplify();

return strm;
}

NumDays::operator double()
{
double temp = days;

temp += (hours / 12.0);
return temp;
}

NumDays:: operator int()
{
return days;
}

// New operators

bool NumDays::operator >= (const NumDays &right)
{
bool status;

if ((*this > right) || (*this == right))
status = true;
else
status = false;

return status;
}

bool NumDays::operator <= (const NumDays &right)
{
bool status;

if ((*this < right) || (*this == right))
status = true;
else
status = false;

return status;
}

bool NumDays::operator != (const NumDays &right)
{
bool status;

if (*this == right)
status = false;
else
status = true;

return status;
}
Last edited on
Every program must have a main() function.

You are probably compiling wrong. I presume you are on *nix?

Make sure you type "g++" followed by the names of all your .cpp files, including those given to you by your professor. For example:

    g++ main.cpp NumDays.cpp

Hope this helps.
Sorry, not quite understanding the *nix
Topic archived. No new replies allowed.