These are my three files.

The header file....

#ifndef MONTH_H
#define MONTH_H
#include <string>
#include <iostream>
using namespace std;

class Month;
ostream &operator<<(ostream &, const Month &);
istream &operator>>(istream &, Month &);

class Month
{
private:
	string month;
	int monthNumber;

public:
	Month();
	Month(string);
	Month(string, int);
	void setName(string);
	void setMonthNumber(int);
	string getName();
	int getMonthNumber();
	Month operator++();
	Month operator++(int);
	Month operator--();
	Month operator--(int);
	friend ostream &operator<<(ostream &, const Month &);
	friend istream &operator>>(istream &, Month &);
	void printMonth();
};
#endif

The CPP file..

#include "Month.h"
#include <iostream>
#include <string>
using namespace std;

Month::Month()
{
	month = "January";
	monthNumber = 1;
}

Month::Month(string m)
{
	month = m;
	if(month == "January")
		monthNumber = 1;
	else if(month == "February")
		monthNumber = 2;
	else if(month == "March")
		monthNumber = 3;
	else if(month == "April")
		monthNumber = 4;
	else if(month == "May")
		monthNumber = 5;
	else if(month == "June")
		monthNumber = 6;
	else if(month == "July")
		monthNumber = 7;
	else if(month == "August")
		monthNumber = 8;
	else if(month == "September")
		monthNumber = 9;
	else if(month == "October")
		monthNumber = 10;
	else if(month == "November")
		monthNumber = 11;
	else if(month == "December")
		monthNumber = 12;
}

Month::Month(string m, int mo)
{
	month = m;
	monthNumber = mo;
}

void Month::setName(string m)
{
	month = m;
}

void Month::setMonthNumber(int m)
{
	monthNumber = m;
}

string Month::getName()
{
	return month;
}

int Month::getMonthNumber()
{
	return monthNumber;
}

Month Month::operator++()
{
	if(month == "January")
		month = "February";
	else if(month == "February")
		month = "March";
	else if(month == "March")
		month = "April";
	else if(month == "April")
		month = "May";
	else if(month == "May")
		month = "June";
	else if(month == "June")
		month = "July";
	else if(month == "July")
		month = "August";
	else if(month == "August")
		month = "September";
	else if(month == "September")
		month = "October";
	else if(month == "October")
		month = "November";
	else if(month == "November")
		month = "December";
	else if(month == "December")
		month = "January";
	
	++monthNumber;
	return *this;
}

Month Month::operator++(int)
{
	Month temp(month, monthNumber);
	
	if(month == "January")
		month = "February";
	else if(month == "February")
		month = "March";
	else if(month == "March")
		month = "April";
	else if(month == "April")
		month = "May";
	else if(month == "May")
		month = "June";
	else if(month == "June")
		month = "July";
	else if(month == "July")
		month = "August";
	else if(month == "August")
		month = "September";
	else if(month == "September")
		month = "October";
	else if(month == "October")
		month = "November";
	else if(month == "November")
		month = "December";
	else if(month == "December")
		month = "January";

	monthNumber++;
	return temp;
}

Month Month::operator--()
{
	if(month == "January")
		month = "December";
	else if(month == "February")
		month = "January";
	else if(month == "March")
		month = "February";
	else if(month == "April")
		month = "March";
	else if(month == "May")
		month = "April";
	else if(month == "June")
		month = "May";
	else if(month == "July")
		month = "June";
	else if(month == "August")
		month = "July";
	else if(month == "September")
		month = "August";
	else if(month == "October")
		month = "September";
	else if(month == "November")
		month = "October";
	else if(month == "December")
		month = "November";

	--monthNumber;
	return *this;
}

Month Month::operator--(int)
{
	Month temp(month, monthNumber);
	if (monthNumber > 1)
		monthNumber--;
	else
		monthNumber = 12;

	if(month == "January")
		month = "December";
	else if(month == "February")
		month = "January";
	else if(month == "March")
		month = "February";
	else if(month == "April")
		month = "March";
	else if(month == "May")
		month = "April";
	else if(month == "June")
		month = "May";
	else if(month == "July")
		month = "June";
	else if(month == "August")
		month = "July";
	else if(month == "September")
		month = "August";
	else if(month == "October")
		month = "September";
	else if(month == "November")
		month = "October";
	else if(month == "December")
		month = "November";

	return temp;
}

void Month::printMonth()
{
	cout << "The month is " << month << " " << monthNumber << endl;
}

ostream &Month::operator<<(ostream &strm, const Month &obj)
{
	strm << "It is month number " << obj.monthNumber << " which is the month of " << obj.month << endl;

	return strm;
}

istream &Month::operator>>(istream &strm, Month &obj)
{
	cin >> obj.monthNumber;
	/*if (obj.monthNumber < 1 || obj.monthNumber > 12)
		obj.monthNumber = 12;

	if(obj.monthNumber == 12)
		obj.month = "December";
	else if(obj.monthNumber == 1)
		obj.month = "January";
	else if(obj.monthNumber == 2)
		obj.month = "February";
	else if(obj.monthNumber == 3)
		obj.month = "March";
	else if(obj.monthNumber == 4)
		obj.month = "April";
	else if(obj.monthNumber == 5)
		obj.month = "May";
	else if(obj.monthNumber == 6)
		obj.month = "June";
	else if(obj.monthNumber == 7)
		obj.month = "July";
	else if(obj.monthNumber == 8)
		obj.month = "August";
	else if(obj.monthNumber == 9)
		obj.month = "September";
	else if(obj.monthNumber == 10)
		obj.month = "October";
	else if(obj.monthNumber == 11)
		obj.month = "November";*/
}

And file main...

#include <iostream>
#include "Month.h"
using namespace std;

int main()
{
	Month month("March");

	month.printMonth();

	month--;

	month.printMonth();

	month++;

	month.printMonth();
	
	cout << month;
	cin >> month;
	cout << month;
	return 0;

}

Keeps giving me erros saying that << and >> is not a member of Month class, see declaration of Month class, and i look and it seems to be all in order. Need help.

Where you wrote ostream &Month::operator<<(ostream &strm, const Month &obj) , you should be writing ostream &operator<<(ostream &strm, const Month &obj) . The function you're defining is not declared as a member function of the Month class.

Edit: (The same goes for your operator>>.)

omg thanks so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.