Ok, I tried a few different things and i'm returning different errors now. Here is the code:
#include <iostream>
#include <string>
using namespace std;
class Time
{
public:
void setHour(int);
void setMinute(int);
int getHour();
int getMinute();
void printTime();
Time(); //default constructor
Time (int, int); //constructor with parameters
private:
int hour;
int minute;
};
Time::Time() //default constructor sets the hour and minute to 0
{
hour = 0;
minute = 0;
}
Time::Time(int hr, int min)
{
hr = hour;
min = minute;
}
class Date
{
public:
void setMonth(int);
void setDay(int);
void setYear(int);
int getMonth();
int getDay();
int getYear();
void printDate();
Date(); //default constructor
Date(int, int, int); //constructor with parameters
private:
int month;
int day;
int year;
};
Date::Date()
{
month = 1;
day = 01;
year = 2000;
}
Date::Date(int mmm, int dd, int yyyy)
{
mmm = month;
dd = day;
yyyy = year;
}
error C2297: '<<' : illegal, right operand has type 'const char [2]'
error C2297: '<<' : illegal, right operand has type 'const char [2]'
warning C4552: '<<' : operator has no effect; expected operator with side-effect
error C2297: '<<' : illegal, right operand has type 'const char [2]'
warning C4552: '<<' : operator has no effect; expected operator with side-effect
error C2296: '<<' : illegal, left operand has type 'void'
error C2297: '<<' : illegal, right operand has type 'const char [12]'
error C2296: '<<' : illegal, left operand has type 'void'
error C2297: '<<' : illegal, right operand has type 'const char [12]'
As you can tell, I am completely new at this and I feel like I am botching up this assignment. Any help would be great.
The insertion/extraction operators (<<, >>) are used with streams (cin, cout, files, string-streams).
The way you are using it eventOne.printName() << " occurs on " So Event::printName must return a valid type, but void Event::printName().
This repeat in several functions.