I have this code working to great now. but I am trying to pretty it up and now I cant see my cout ... Maybe a new set of eyes on it will help me. I am missing something .. I may have deleted a cout but I dont see it.

thanks for any help

I'm getting a "Debug assertion failed" error in Visual Studio in the loop in lines 79 and 80. Note: I had to change the code in line 42 from "Contributor.h" to "contributor.h" to match the filename.

//***************************************************************
// TITLE:                      	Contributor	
// FILEInContrib:               Contributor.cpp
// PREPARED FOR:               	CS230 Section <section number>
// PROGRAMMER(S):              	< Phillip Harris>
// DEVELOPMENT DATE:           	< 08/09/08>
// COMPILER USED:      		    <MS visual studio 2005>
// TARGET PLATFORM:         	< WIN XP >
//================================================================
//                   PROJECT FILES
//    	contributor.h, contributor.cpp,	Lab1.cpp
//================================================================
//                          REVISION HISTORY
//   DATE     PROGRAMMER            DESCRIPTION OF CHANGES MADE
//	<08/08/08	Phil Harris				Original >
//================================================================

// Program Description/ test plan : This program separates Male and Female by amount of their 
// contribution. if there is more of one gender than the other, the program will 
// add them to the end of the table. 
	
//	Program implementation commented within program

// INPUTS:	  Randomly generated Contributors from class Contributor.

// OUTPUTS:	 List of the seating arrangement in required order.
//=============================================================================
//		CONSTANT DEFINITIONS
//			   NONE
//=============================================================================
//		EXTERNAL CLASS VARIABLES
//			   NONE
//=============================================================================
//		INCLUDE FILES
#include<iostream>
#include<string>
#include<cassert>
#include<list>
#include<stack>
#include<cstdlib>   
#include<ctime>	  
#include "contributor.h"
using namespace std;

//		BEGINNING OF MAIN PROGRAM CODE
//*****************************************************************************
int main()
     {
       int num= 1;
       	list <Contributor> F_list; //make a list of contributors
	    list <Contributor> M_list;
     	list <Contributor>::iterator F_ITR = F_list.begin();// this is initializes the iterator
      	list <Contributor>::iterator M_ITR = M_list.begin();
       	stack <Contributor> F_stack;//makes the stacks for Male/Female
        stack <Contributor> M_stack;
        stack <Contributor>LHS_stack;//Makes the left side of the table 
        stack <Contributor>RHS_stack;
        stack <Contributor>rTable_stack;//makes the table stack
        
///\/\/\/\/\/\/\/ Prof Thors Random ALGOR /\/\/\/\/\/\/\/\/\/					   
	srand ((unsigned) time (NULL)); 
	  for (int counter=0; counter<100;counter++)
		{
			double Con=rand()% 1000;
			int Sex=rand()%10; 			
			if(Sex>4)
			{
 		      Contributor Dude("Male", Con, Male, 1234); 	
			  M_list.insert(M_ITR, Dude);
			}else{
 		      Contributor lady("Lady", Con, Female, 1234); 	
			  F_list.insert(F_ITR, lady);	
			}
		}
    	M_list.sort();
		F_list.sort();

///\/\/\/\/\/\/\/\Pus to the stack ... highest to lowest  /\/\/\/\/\/\/\/\/\
for (M_ITR=M_list.begin(); M_ITR!=M_list.end(); ++M_ITR)
      M_stack.push(*M_ITR);
for (F_ITR=F_list.begin(); F_ITR!=F_list.end(); ++F_ITR)
      F_stack.push(*F_ITR);
      cout<<"Male stack number: " << (int) M_stack.size() << endl;
	  cout<<"Female stack number: " << (int) F_stack.size() <<endl;

///\/\/\/\/\/\/\/\/\/Alternate the Gender/\/\/\\/\/\/\/\/\/\/\/\/\
for (int i = 0; i <100; i++)
   {
     if((!M_stack.empty()) && (!F_stack.empty()))
       {
         LHS_stack.push(M_stack.top()); 
	     M_stack.pop();
       }
     if((!M_stack.empty()) && (!F_stack.empty()))
   	   {
         RHS_stack.push(F_stack.top());
     	 F_stack.pop();
       }
     if((!M_stack.empty()) && (!F_stack.empty()))
       {
         RHS_stack.push(M_stack.top());
	     M_stack.pop();
       }
	 if((!M_stack.empty()) && (!F_stack.empty()))
       {
		 LHS_stack.push(F_stack.top()); 
		 F_stack.pop();
       }
   }
cout<<"Male stack: "<<M_stack.size()<<endl;
cout<<"Female stack: "<<F_stack.size()<<endl<<endl;
cout<<"Left side: "<<LHS_stack.size()<<endl;
cout<<"Right side: "<<RHS_stack.size()<<endl<<endl;
					

//move rest of males (or females) left and right
while (!M_stack.empty())
  {
    if (!M_stack.empty())		 
       {
        LHS_stack.push(M_stack.top());  
        M_stack.pop();	  
       }

  if(!M_stack.empty())		 
  {
     RHS_stack.push(M_stack.top());	
     M_stack.pop();
  }
 }									  

while (!F_stack.empty())
  {
    if (!F_stack.empty())
	   {
	     LHS_stack.push(F_stack.top()); 
	     F_stack.pop();
	   }

    if (!F_stack.empty())
       {
	    RHS_stack.push(F_stack.top());
	    F_stack.pop();
       }
  }
		  
//RESTACK RIGHT SIDE LIST BEFORE PRINTING

while(!RHS_stack.empty())
     {
	   rTable_stack.push(RHS_stack.top());
	   RHS_stack.pop();
     }
cout<<"RHS_stack made"<<endl;
cout<<"Seating arrangement - from Left to Right "<<endl;
   
while(!LHS_stack.empty()) 
      {
	    cout<<" "<<LHS_stack.top();
	    LHS_stack.pop();
      }	
       cout<<endl;
       cout<<"Guest Speaker:  Geuest speaker"<<endl<<endl;
		
while(!rTable_stack.empty())
      {
       cout<<" "<<rTable_stack.top();
       rTable_stack.pop();
      }
cin>>num;
return 0;
}
//******************************************************************************
//		END OF MAIN PROGRAM CODE
//******************************************************************************

Venom
Yea man that is the same thing I am getting in Dev C++. I had it working fine before I giggled it ... I wonder waht I did

Venom
Yea man that is the same thing I am getting in Dev C++. I had it working fine before I giggled it ... I wonder waht I did

It looks to me like these comments on lines 78 and 86 are a problem. I deleted them and the program ran. Some type of unseen stray character or something that makes the compiler not realize when the comment is over?

The ending backslash works as a continuation character, turning the following line into a comment too.

I have this code working to great now. but I am trying to pretty it up and now I cant see my cout ... Maybe a new set of eyes on it will help me. I am missing something .. I may have deleted a cout but I dont see it.

thanks for any help

hey bro how did you get the function to work properly

commented: They read the rest of the thread quietly a year ago -7
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.