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.

New Topic/Question
Reply



MultiQuote



|