Hello,
I am currently working on a school assignment, and I have spent a great amount of time on this, but I am coming up with a couple of error messages that I can't figure out. Here is my code:

#include <iostream>
#include <string>
	 
using namespace std;
 
class Date
{
public:
	Date();	//default constructor
	Date(int month, int day, int year);	//constructor with parameters
	void setMonth(int);
	void setDay(int);
	void setYear(int);
	int getMonth();
	int getDay();
	int getYear();
	void printDate();
private:
	int month;
	int day;
	int year;
};
 
class Time
{
public:
	Time(); //constructor
	Time(int, int);	//constructor with parameters
	void setHour(int);
	void setMinute(int);
	int getHour();
	int getMinute();
	void printTime();
private:
	int hr;
	int min;
};
 
class Event
{
public:
	Event(); //constructor
	Event(string, int, int, int, int, int);	//constructor with parameters
	string getName();
	void printName();
	void printDate();
	void printTime();
private:
	string EventName;
	Time EventTime;
	Date EventDate;
	
};
 
Date::Date()
{
	month = 03;
	day = 17;
	year = 2011;
}
 
Date::Date(int mm, int dd, int yyyy)
{
	month = mm;
	day = dd;
	year = yyyy;
}
 
void Date::setMonth(int mm)
{
	if(03 <= mm && mm <= 12)
		mm = month;
	else
		month = 03;
}
 
void Date::setDay(int dd)
{
	if(17 <= dd && dd <= 31)
		dd = day;
	else
		day = 17;
}
 
void Date::setYear(int yyyy)
{
	if(0 <= yyyy && yyyy <= 2020)
		yyyy = year;
	else 
		year = 2011;
}
 
int	Date::getMonth()
{
	return month;
}
 
int Date::getDay()
{
	return day;
}
 
int Date::getYear()
{
	return year;
}
 
void Date::printDate()
{
	cout << getMonth() << "/" << getDay() << "/" << getYear();
};
 
Time::Time() //default constructor sets the hour and minute
{
	hr = 0;
	min = 0;
}
 
Time::Time (int hour, int minute)
{
	hr = hour;
	min = minute;
}
 
void Time::setHour (int hour)
{
	if(0 <= hour && hour < 24)
		hr = hour;
	else
		hr = 0;
}
 
void Time::setMinute(int minute)
{
	if(0 <= minute && minute < 60)
		min = minute;
	else
		min = 0;
}
 
int Time::getHour()
{
	return hr;
}
 
int Time::getMinute()
{
	return min;
};
 
void Time::printTime()
{ 
	cout << getHour() << ":" << getMinute();
}
 
Event::Event()
{
 
}
 
Event::Event(string eName, int eHour, int eMinute, int eMonth, int eDay, int eYear)
{
	EventName = eName;
    EventTime.setHour(eHour);
	EventTime.setMinute(eMinute);
	EventDate.setMonth(eMonth);
	EventDate.setDay(eDay);
	EventDate.setYear(eYear);
}
 
string Event::getName()
{
	return EventName;
}
 
void Event::printName()
{
	cout << EventName;
}
 
void Event::printDate()
{
	cout << EventDate.getMonth() << "/" << EventDate.getDay() << "/" << EventDate.getYear();
}
 
void Event::printTime()
{
	cout << EventTime.getHour() << ":" << EventTime.getMinute();
}
 
int main()
{
	Event eventOne ("New Years Day", 00, 01, 01, 01, 2011);
	Event eventTwo ("Valentines Day", 12, 15, 02, 14, 2011);

	eventOne.printName();
	cout << " occurs on " ;
	eventOne.printDate();
	cout << " at " ;
	eventOne.printTime();
	cout << "." << endl;
	eventTwo.printName();
	cout << " occurs on ";
	eventTwo.printDate();
	cout << " at ";
	eventTwo.printTime();
	cout << "." << endl;
	cout << endl;
	 
	return 0;
}

And my errors is as follows:
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

fatal error LNK1120: 1 unresolved externals
if there is any ideas, it would be greatly appreciated for I have spent too much time staring at the screen and can not find the problem.

You have chosen the wrong kind of project. You need to choose a Win32 Console Application from the initial menu. Start a new project and copy your code in, you should be good to go.

Edited 5 Years Ago by jonsca: n/a

That worked. I thought I clicked on the Win32 console button, but I guess I didn't. Thank you very much.

This article has been dead for over six months. Start a new discussion instead.