VS Keeps Giving Me Hell

My "DayOfTheWeek" code won't compile

Page 1 of 1

3 Replies - 3323 Views - Last Post: 08 March 2009 - 03:17 PM Rate Topic: -----

#1 cPluPlu   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 23-July 08

VS Keeps Giving Me Hell

Posted 08 March 2009 - 12:20 AM

I am supposed to write a program that contains a class that implements the days of the week. The program should be able to perform the following on an object of the class.

1. Set the day
2. Print the day to the computer monitor (not the printer)
3. Return the day

I made the mistake of not building my code as I went along, so now I get the error, "1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup".

Here is my code:

 #pragma once
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

class DayOfTheWeek
{
public:
	DayOfTheWeek(void); //constructor
	~DayOfTheWeek(void); //destructor
	string getHour(); //gets hour of week
	void setHour(string); //sets the hour of the week
	string getDay(); //gets the day of the week
	void setDay(string); //sets the day of the week
	void printDay(); //prints the day and the hour of the week

private:
	string day; //day of the week
	string hour; //hour of the week

};

#include "DayOfTheWeek.h"

DayOfTheWeek::DayOfTheWeek(void)
{
	day  = "default";
	hour = "default";
}

DayOfTheWeek::~DayOfTheWeek(void)
{
}

string DayOfTheWeek::getHour()
{
	string tempHour;

	cout << "Enter Hour: ";
	cin  >> tempHour;

	return tempHour;
}

void DayOfTheWeek::setHour(string HourOfWeek)
{
	hour = HourOfWeek;
}

string DayOfTheWeek::getDay()
{
	string tempDay;

	cout << "Enter Day: ";
	cin  >> tempDay;

	return tempDay;
}

void DayOfTheWeek::setDay(string DayOfWeek)
{
	day = DayOfWeek;
}

void DayOfTheWeek::printday()
{
	cout << "The Day Is : " << day << endl;
	cout << "The Hour Is: " << hour << endl << endl;
}


int main()
{
	string HourOfDay = "";		 //Hour of day
	string DayOfWeek = "";		 //Day of week

	DayOfTheWeek DayOne;			 //Day 1
	DayOfTheWeek DayTwo;			 //Day 2

	HourOfDay = DayOne.getHour();  //Get the day of day 1
	DayOne.setHour(HourOfDay);	 //Set the day of day 1

	DayOfWeek = DayOne.getDay();   //Get the hour of day 1
	DayOne.setDay(DayOfWeek);	  //Set the hour of day 1

	HourOfDay = DayTwo.getHour();  //Get the day of day 2
	DayTwo.setHour(HourOfDay);	 //Set the day of day 2

	DayOfWeek = DayTwo.getDay();   //Get the hour of day 2
	DayTwo.setDay(DayOfWeek);	  //Set the hour of day 2

	DayOne.printday();			 //Display information on day 1

	DayTwo.printday();			 //Display information on day 2
   
	return 0;
}




The finished product is due Sunday night, and I've been doing fairly well up until now.

Is This A Good Question/Topic? 0
  • +

Replies To: VS Keeps Giving Me Hell

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: VS Keeps Giving Me Hell

Posted 08 March 2009 - 12:21 AM

Here is a solution via the MSDN forums.
Was This Post Helpful? 0
  • +
  • -

#3 cPluPlu   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 23-July 08

Re: VS Keeps Giving Me Hell

Posted 08 March 2009 - 02:42 PM

View Postno2pencil, on 7 Mar, 2009 - 11:21 PM, said:

Here is a solution via the MSDN forums.


I checked out the forums, and changed the subsystem to WINDOWS. I rebuilt it, and now I'm getting 2 errors:

(4) : error C2084: function 'DayOfTheWeek::DayOfTheWeek(void)' already has a body
(11) : see previous definition of '{ctor}'
(8) : error C2084: function 'DayOfTheWeek::~DayOfTheWeek(void)' already has a body
(12) : see previous definition of '{dtor}'

 #pragma once
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

class DayOfTheWeek
{
public:
	DayOfTheWeek(void); //constructor
	~DayOfTheWeek(void); //destructor
	string getHour(); //gets hour of week
	void setHour(string); //sets the hour of the week
	string getDay(); //gets the day of the week
	void setDay(string); //sets the day of the week
	void printDay(); //prints the day and the hour of the week

private:
	string day; //day of the week
	string hour; //hour of the week

};

#include "DayOfTheWeek.h"

DayOfTheWeek::DayOfTheWeek(void)
{
	day  = "default";
	hour = "default";
}

DayOfTheWeek::~DayOfTheWeek(void)
{
}

string DayOfTheWeek::getHour()
{
	string tempHour;

	cout << "Enter Hour: ";
	cin  >> tempHour;

	return tempHour;
}

void DayOfTheWeek::setHour(string HourOfWeek)
{
	hour = HourOfWeek;
}

string DayOfTheWeek::getDay()
{
	string tempDay;

	cout << "Enter Day: ";
	cin  >> tempDay;

	return tempDay;
}

void DayOfTheWeek::setDay(string DayOfWeek)
{
	day = DayOfWeek;
}

void DayOfTheWeek::printDay()
{
	cout << "The Day Is : " << day << endl;
	cout << "The Hour Is: " << hour << endl << endl;
}


int main()
{
	string HourOfDay = "";		 //Hour of day
	string DayOfWeek = "";		 //Day of week

	DayOfTheWeek DayOne;			 //Day 1
	DayOfTheWeek DayTwo;			 //Day 2

	HourOfDay = DayOne.getHour();  //Get the day of day 1
	DayOne.setHour(HourOfDay);	 //Set the day of day 1

	DayOfWeek = DayOne.getDay();   //Get the hour of day 1
	DayOne.setDay(DayOfWeek);	  //Set the hour of day 1

	HourOfDay = DayTwo.getHour();  //Get the day of day 2
	DayTwo.setHour(HourOfDay);	 //Set the day of day 2

	DayOfWeek = DayTwo.getDay();   //Get the hour of day 2
	DayTwo.setDay(DayOfWeek);	  //Set the hour of day 2

	DayOne.printDay();			 //Display information on day 1

	DayTwo.printDay();			 //Display information on day 2
   
	return 0;
}



Was This Post Helpful? 0
  • +
  • -

#4 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3213
  • View blog
  • Posts: 19,241
  • Joined: 14-September 07

Re: VS Keeps Giving Me Hell

Posted 08 March 2009 - 03:17 PM

Have you tried making an entirely new project and copy/pasting the code into it? I can compile that fine, without errors. For VS, unless I need some precompiled crap MS gives me, I always make a blank project and add as I need.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1