#include <iostream>
using namespace std;
 
class Month
{
public:
  Month (char char1, char char2, char  char3);
  // Precondition: The parameters contain the first three characters
  // in the name of the month - all lowercase.
  // Postcondition: The member variable month has been set to
  // the integer value corresponding to the letters (1 for jan, 
  // (2 for feb, and so on). month is set to 0 and a message is
  // printed if the letters do not correspond to a valid month.
 
  Month (int monthNum);
  // Precondition: The parameter monthNum contains a valid 
  // month number (1 - 12)
  // Postcondition: The member variable month has been set to 
  // the value of the parameter monthNum.
 
  Month();
  // Sets the member variable month to 1 (defaults to January).
 
  void Input (istream& in);
  // Postcondition: The member variable month has been output
  // to the screen if it is valid; otherwise a "not valid"
  // message is printed.
 
  void Output(ostream& outs);
  // Postcondition: The first three letters of the name of the
  // month has been output to the screen if the month is
  // valid (1 - 12); otherwise a message indicating the month
  // is not valid is output
  Month Next();

 
private:
  int month;
  
};
 
 
 void main ()
{
	 
	 Month m1;
	 Month m2;
	
	 cout<<" enter month"<< endl;

	 m1.Input(cin);
	 
	 m2.Output(cout);     
}

 Month::Month(): month(month)
{
	 

}
  void	Month::Input(istream& in)
{
  char first,second,third;
  int number_month;
  char c;
  
  c=in.peek();

  if( (c > '0') && (c <= '9'))
		{
		in >> number_month;
		Month(nuber_month);
		
		}
  
	 else
	  {
		in >>first>>second>>third;
		Month(first,second,third);
		
		
	  }

  }
Month::Month(char char1, char char2, char char3)
{	
    
            	
	    if( (char1=='j'|| char1 =='J') && (char2=='a'|| char2=='A')&&(char3=='n'|| char3=='N'))
		{	month=1;
		cout<< month;
		Month(month);}
		if(( char1=='f' || char1=='F') && (char2 == 'e' || char2 == 'E') && ( char3 == 'b'|| char3=='B'))
		{month=2;}
        if(( char1=='m' || char1=='M') && (char2 == 'a' || char2 == 'A') && ( char3 == 'r'|| char3=='R'))
		{month=3;
		cout<< month;}
		if(( char1=='a' || char1=='A') && (char2 == 'p' || char2 == 'P') && ( char3 == 'r'|| char3=='R'))
		{month=4;
		cout<< month;}
		if(( char1=='m' || char1=='M') && (char2 == 'a' || char2 == 'A') && ( char3 == 'y'|| char3=='Y'))
		{month=5;
		cout<< month;}
		if(( char1=='j' || char1=='J') && (char2 == 'u' || char2 == 'U') && ( char3 == 'n'|| char3=='N'))
		{month=6;
		cout<< month;}

		if(( char1=='j' || char1=='J') && (char2 == 'u' || char2 == 'U') && ( char3 == 'l'|| char3=='L'))
		{month=7;
		}
		if(( char1=='a' || char1=='A') && (char2 == 'u' || char2 == 'U') && ( char3 == 'g'|| char3=='G'))
		{month=8;
		}
		if(( char1=='s' || char1=='S') && (char2 == 'e' || char2 == 'E') && ( char3 == 'p'|| char3=='P'))
		{month=9;
		cout<< month;}

		if(( char1=='o' || char1=='O') && (char2 == 'c' || char2 == 'C') && ( char3 == 't'|| char3=='T'))
		{month= 10;}
		
		if((char1=='n' || char1=='N') && (char2 == 'o' || char2 == 'O') && ( char3 == 'v'|| char3=='V'))
		{month=11;}
	    if(( char1=='d' || char1=='D') && (char2 == 'e' || char2 == 'E') && ( char3 == 'c'|| char3=='C'))
		{month=12;}
	
		    cout<<endl<<char1<<char2<<char3;
		
Month(month);
}
 Month::Month(int monthNum)
{
	 
	if (monthNum>0 && monthNum<=12)
		
	month=monthNum;
	else
	{
	}
		
}
 /* here is the problem it is taking the default value to do the switch and 
not the value that month just 
 got in the previous function. why is it doing that or is that i am using the wrong concepts???*/
void Month:: Output(ostream& outs)
{	 

  switch (month)
    {
    case 1:
      outs<< "January" <<endl;
      break;
    case 2:
      outs << "February" <<endl;
      break;
    case 3:
      outs << "March" <<endl;
      break;
    case 4:
      outs << "April" <<endl;
      break;
    case 5:
      outs << "May" <<endl;
      break;
    case 6:
      outs << "June" <<endl;
      break;
    case 7:
      outs << "July" <<endl;
      break;
    case 8:
      outs << "August" <<endl;
      break;
    case 9: 
      outs << "September" <<endl;
      break;
    case 10:
      outs << "October" <<endl;
      break;
    case 11:
      outs << "November" <<endl;
      break;
    case 12:
      outs << "December" <<endl;
      break;
    default:
      outs << "Sorry incorect Month " <<endl;
    }
  
}


	Month  Month :: Next()
{
		int next;
	if (month==12)
		next=1;
	else
	{
		 next=month++;
	}
	cout<< next;
	return( Month(next));
}

One, use code tags and formatting. Way too much code to look at without code tags, formatting, line numbers:

[code=cplusplus] // paste code here

[/code]

Two, don't just paste a bunch of code up. What's the question? Does it compile? Does it run? Does it crash? What's the error? line number? Etcetera etcetera.

I think the problem is that your input method is then calling a constructor, which sets the month variable of a new, unallocated instance of Month. The instance m1 in main( ) does not get modified. You can see this if you step through the program, watching the value month as it goes through the mass of if statements. (You really should use if...else blocks)

Your two constructors

Month::Month(char char1, char char2, char char3)
Month (int monthNum)

probably should be changed to mutator functions, which can be called by the appropriate constructors.

1. Always use tag CODE to post your snippets:
[code=cplusplus] your code

[/code]
2. Senseless member function does not assign any value to month:

void Month::Input(istream& in) {
    char first,second,third;
    int number_month;
    char c;

    c=in.peek();

    if ( (c > '0') && (c <= '9'))   {
        in >> number_month;
        Month(nuber_month);
        // Create a new local Month object
    }  // Discard this object. No effect...
}

Yet another null effect member function - Month constructor:

Month::Month(): month(month) // initialize month with garbage value
{} // the same as: Let month is equal to don't know what is it...

Obvious correction needed (do it yourself).
What's an awful sight... Unnecessary switches cascade...

Two, don't just paste a bunch of code up. What's the question? Does it compile? Does it run? Does it crash? What's the error? line number? Etcetera etcetera.

There is a question, buried deep in the code in a comment block.

Agree, it's a poor way to post. I was about to also ask what the problem was when I saw the query.

hey thank you for the comment but like u said it is too mesy i will try to post it againg so i can understand ur answer better thank you;/

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.