hello all
I am a second semester c++ college kid so bear with me

I am writing a program that takes in bank account info, sorts it, prints it, and then prompts the user if they would like to view any specific records via the account number or the name on the account

we have to compile in the terminal and code in Vi and here are the compile errors I am getting:

assign6.cpp: In member function ‘bool cAccountList::search()’:
assign6.cpp:174: error: void value not ignored as it ought to be
assign6.cpp:176: error: void value not ignored as it ought to be


i have never worked with the bool data type so I dont know if fuctions using it are more picky etc....

here is my code:

//Assignment #6 due 2-8-2010
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
//global declarations
typedef char Name_t[15];
typedef fstream Infile_t;
typedef fstream Outfile_t;
typedef char Filename_t[50];
//*********************************************************************************************************
//classes
class cAccount
{
	private:
		int accountID;
		Name_t accountName;//(last,first)
		float accountBal;
	public:
		cAccount();
		int get_accountID(int &accountID)
		{ accountID=this->accountID; return accountID;};
		void get_accountName(Name_t &accountName)
		{ strcpy(accountName,this->accountName);};
		void read(Infile_t &Infile);
		void print(Outfile_t &Outfile);
		void display();
};//end of cAccount
class cAccountList
{
	private:
		static const int MAXARRAYSIZE=51;
		int counter;
		typedef cAccount AccountArray[MAXARRAYSIZE];
		AccountArray AccountList;
	public:
		cAccountList();
		void load_data(Infile_t &Infile);
		void print_to_outfile(Outfile_t &Outfile);
		void print_to_screen();
		void sort_by_ID();
		bool search();
};//end of cAccountList
//*********************************************************************************************************
//class cAccount functions
cAccount::cAccount()
{
	accountID=0;
	accountBal=0;
};//default constructor
void cAccount::read(Infile_t &Infile)
{ Infile>>accountID>>accountName>>accountBal; };
//end of cAccount::Read
void cAccount::print(Outfile_t &Outfile)
{ 
	Outfile<<" "<<accountID<<" "<<accountName<<" "<<accountBal<<endl;
	Outfile<<"_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"<<endl;
};//end of print
void cAccount::display()
{
	cout<<" "<<accountID<<" "<<accountName<<" "<<accountBal<<endl;
	cout<<"***********************************************************"<<endl;
};//end of display
//*********************************************************************************************************
//class cAccountList functions  
cAccountList::cAccountList()
{ counter=0; };//default constructors
void cAccountList::load_data(Infile_t &Infile)
{
	Filename_t Filename;
	cout<<"Please enter the name of the datafile to be used:"<<endl;
	cin>>Filename;
	Infile.open(Filename,ios::in);
	AccountList[counter].read(Infile);
	while(!Infile.eof())
	{
		counter=counter+1;
		AccountList[counter].read(Infile);
	}//end while
	Infile.close();
	cout<<"Datafile read....SUCCESS!"<<endl;
};//end of read_data
void cAccountList::print_to_outfile(Outfile_t &Outfile)
{
	Filename_t Filename;
	cout<<"Please enter the name of the output file:"<<endl;
	cin>>Filename;
	Outfile.open(Filename,ios::out);
	Outfile<<"**************************************************************"<<endl;
	Outfile<<" "<<"ACCOUNT_ID#"<<" "<<"ACCOUNT_NAME"<<" "<<"ACCOUNT_BALANCE"<<endl;
	Outfile<<"**************************************************************"<<endl<<endl;
	for(int I=0; I<counter; I++)
	{
		AccountList[I].print(Outfile);
	}//end for
	Outfile.close();
	cout<<"Outfile write...SUCCESS!"<<endl<<endl;
};//end print_to_outfile
void cAccountList::print_to_screen()
{
	char choice[2];
	cout<<"Would you like to preview your output file? (Y/N)"<<endl;
	cin>>choice;
	if (strcmp(choice,"N")!=0)
	{
		cout<<"Generating preview of output....."<<endl<<endl;
		cout<<"**************************************************************"<<endl;
		cout<<" "<<"ACCOUNT_ID#"<<" "<<"ACCOUNT_NAME"<<" "<<"ACCOUNT_BALANCE"<<endl;
		cout<<"**************************************************************"<<endl<<endl;
		for(int I=0; I<counter; I++)
		{
			AccountList[I].display();
		}//end for
	}//end if
	else
	{ cout<<"Very well...MOVING TO NEXT PROCESS"<<endl;}
}//end print_to_screen
void cAccountList::sort_by_ID()
{
	int I,Pass;
	int accountID;
	AccountArray temp;
	for(Pass=1; Pass<counter-1; Pass++)
	{
		for(I=0; I<counter-1; I++)
		{
		if(AccountList[I].get_accountID(accountID) > AccountList[I+1].get_accountID(accountID))
		{
			temp[I]=AccountList[I];
			AccountList[I]=AccountList[I+1];
			AccountList[I+1]=temp[I];
		}//end if
		}//end inside for
	}//end outside for
}//end sort_by_ID
bool cAccountList::search()
{
	bool Found=false;
	int I=0;
	int accountID;
	int searchID=0;
	Name_t searchName;
	Name_t accountName;
	char choice[2];
	char choice_2[10];
	cout<<"Would you like to search for a record at this time? (Y/N)"<<endl;
	cin>>choice;
	while(strcmp(choice,"N")!=0)
	{
		cout<<"Would you like to search by ID# or Name?"<<endl;
		cout<<"If by ID then enter 'ID', if by Name then enter 'Name'..."<<endl;
		cin>>choice_2;
		if(choice_2=="ID")
		{
			cout<<"Please enter the 5 digit ID number:"<<endl;
			cin>>searchID;
			while((!Found)&&(I<counter))
			{
				if(AccountList[I].get_accountID(accountID)!=searchID)
				{ I=I+1;}//end if
				else if (AccountList[I].get_accountID(accountID)==searchID)
				{ Found=true;}//end else
			}//end interior while
			return Found;
		}//option one
		else 
		if(choice_2=="Name")
		{
			cout<<"Please enter the account name:"<<endl;
			cout<<"**NOTE** account name should be in (lastname,firstname) format!!!"<<endl;
			cin>>searchName;
			while((!Found)&&(I<counter))
			{
				if(AccountList[I].get_accountName(accountName)!=searchName)
				{ I=I+1;}//end if
				else if (AccountList[I].get_accountName(accountName)==searchName)
				{ Found=true;}//end else
			}//end interior while
			return Found;
		}
		else
		{
			cout<<"PLEASE ENTER A VALID CHOICE!!!"<<endl;
		}
		cout<<"Would you like to search for another record? (Y/N)"<<endl;
		cin>>choice;
	}//end while
}//end search	
//*********************************************************************************************************
//main
int main()
{
	Infile_t Infile;
	Outfile_t Outfile;
	cAccountList ACCOUNT;
	ACCOUNT.load_data(Infile);
	ACCOUNT.sort_by_ID();
	ACCOUNT.print_to_outfile(Outfile);
	ACCOUNT.print_to_screen();
return 0;
}//end main
//********************************************************************************************************

does anyone know whats going on??
thanks

It's nothing to do with bool. At lines 174 and 176 you attempt to compare the value returned by get_accountName to some string. However, get_accountName is declared void ; it returns nothing. The compiler tells you just that.

that worked but now I am getting a whole slew of new errors when I try to compile the same code on my home ubuntu machine

here are the new compiler errors:

assign6.cpp: In member function ‘char cAccount::get_accountName(char (&)[15])’:
assign6.cpp:24: error: ‘strcpy’ was not declared in this scope
assign6.cpp: In member function ‘void cAccountList::print_to_screen()’:
assign6.cpp:104: error: ‘strcmp’ was not declared in this scope
assign6.cpp: In member function ‘bool cAccountList::search()’:
assign6.cpp:148: error: ‘strcmp’ was not declared in this scope
assign6.cpp:174: error: ISO C++ forbids comparison between pointer and integer
assign6.cpp:176: error: ISO C++ forbids comparison between pointer and integer

here is my code:

//Assignment #6 due 2-8-2010
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
//global declarations
typedef char Name_t[15];
typedef fstream Infile_t;
typedef fstream Outfile_t;
typedef char Filename_t[50];
//*********************************************************************************************************
//classes
class cAccount
{
	private:
		int accountID;
		Name_t accountName;//(last,first)
		float accountBal;
	public:
		cAccount();
		int get_accountID(int &accountID)
		{ accountID=this->accountID; return accountID;};
		char get_accountName(Name_t &accountName)
		{ strcpy(accountName,this->accountName); return accountID;};
		void read(Infile_t &Infile);
		void print(Outfile_t &Outfile);
		void display();
};//end of cAccount
class cAccountList
{
	private:
		static const int MAXARRAYSIZE=51;
		int counter;
		typedef cAccount AccountArray[MAXARRAYSIZE];
		AccountArray AccountList;
	public:
		cAccountList();
		void load_data(Infile_t &Infile);
		void print_to_outfile(Outfile_t &Outfile);
		void print_to_screen();
		void sort_by_ID();
		bool search();
};//end of cAccountList
//*********************************************************************************************************
//class cAccount functions
cAccount::cAccount()
{
	accountID=0;
	accountBal=0;
};//default constructor
void cAccount::read(Infile_t &Infile)
{ Infile>>accountID>>accountName>>accountBal; };
//end of cAccount::Read
void cAccount::print(Outfile_t &Outfile)
{ 
	Outfile<<" "<<accountID<<" "<<accountName<<" "<<accountBal<<endl;
	Outfile<<"_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"<<endl;
};//end of print
void cAccount::display()
{
	cout<<" "<<accountID<<" "<<accountName<<" "<<accountBal<<endl;
	cout<<"***********************************************************"<<endl;
};//end of display
//*********************************************************************************************************
//class cAccountList functions  
cAccountList::cAccountList()
{ counter=0; };//default constructors
void cAccountList::load_data(Infile_t &Infile)
{
	Filename_t Filename;
	cout<<"Please enter the name of the datafile to be used:"<<endl;
	cin>>Filename;
	Infile.open(Filename,ios::in);
	AccountList[counter].read(Infile);
	while(!Infile.eof())
	{
		counter=counter+1;
		AccountList[counter].read(Infile);
	}//end while
	Infile.close();
	cout<<"Datafile read....SUCCESS!"<<endl;
};//end of read_data
void cAccountList::print_to_outfile(Outfile_t &Outfile)
{
	Filename_t Filename;
	cout<<"Please enter the name of the output file:"<<endl;
	cin>>Filename;
	Outfile.open(Filename,ios::out);
	Outfile<<"**************************************************************"<<endl;
	Outfile<<" "<<"ACCOUNT_ID#"<<" "<<"ACCOUNT_NAME"<<" "<<"ACCOUNT_BALANCE"<<endl;
	Outfile<<"**************************************************************"<<endl<<endl;
	for(int I=0; I<counter; I++)
	{
		AccountList[I].print(Outfile);
	}//end for
	Outfile.close();
	cout<<"Outfile write...SUCCESS!"<<endl<<endl;
};//end print_to_outfile
void cAccountList::print_to_screen()
{
	char choice[2];
	cout<<"Would you like to preview your output file? (Y/N)"<<endl;
	cin>>choice;
	if (strcmp(choice,"N")!=0)
	{
		cout<<"Generating preview of output....."<<endl<<endl;
		cout<<"**************************************************************"<<endl;
		cout<<" "<<"ACCOUNT_ID#"<<" "<<"ACCOUNT_NAME"<<" "<<"ACCOUNT_BALANCE"<<endl;
		cout<<"**************************************************************"<<endl<<endl;
		for(int I=0; I<counter; I++)
		{
			AccountList[I].display();
		}//end for
	}//end if
	else
	{ cout<<"Very well...MOVING TO NEXT PROCESS"<<endl;}
}//end print_to_screen
void cAccountList::sort_by_ID()
{
	int I,Pass;
	int accountID;
	AccountArray temp;
	for(Pass=1; Pass<counter-1; Pass++)
	{
		for(I=0; I<counter-1; I++)
		{
		if(AccountList[I].get_accountID(accountID) > AccountList[I+1].get_accountID(accountID))
		{
			temp[I]=AccountList[I];
			AccountList[I]=AccountList[I+1];
			AccountList[I+1]=temp[I];
		}//end if
		}//end inside for
	}//end outside for
}//end sort_by_ID
bool cAccountList::search()
{
	bool Found=false;
	int I=0;
	int accountID;
	int searchID=0;
	Name_t searchName;
	Name_t accountName;
	char choice[2];
	char choice_2[10];
	cout<<"Would you like to search for a record at this time? (Y/N)"<<endl;
	cin>>choice;
	while(strcmp(choice,"N")!=0)
	{
		cout<<"Would you like to search by ID# or Name?"<<endl;
		cout<<"If by ID then enter 'ID', if by Name then enter 'Name'..."<<endl;
		cin>>choice_2;
		if(choice_2=="ID")
		{
			cout<<"Please enter the 5 digit ID number:"<<endl;
			cin>>searchID;
			while((!Found)&&(I<counter))
			{
				if(AccountList[I].get_accountID(accountID)!=searchID)
				{ I=I+1;}//end if
				else if (AccountList[I].get_accountID(accountID)==searchID)
				{ Found=true;}//end else
			}//end interior while
			return Found;
		}//option one
		else 
		if(choice_2=="Name")
		{
			cout<<"Please enter the account name:"<<endl;
			cout<<"**NOTE** account name should be in (lastname,firstname) format!!!"<<endl;
			cin>>searchName;
			while((!Found)&&(I<counter))
			{
				if(AccountList[I].get_accountName(accountName)!=searchName)
				{ I=I+1;}//end if
				else if (AccountList[I].get_accountName(accountName)==searchName)
				{ Found=true;}//end else
			}//end interior while
			return Found;
		}
		else
		{
			cout<<"PLEASE ENTER A VALID CHOICE!!!"<<endl;
		}
		cout<<"Would you like to search for another record? (Y/N)"<<endl;
		cin>>choice;
	}//end while
}//end search	
//*********************************************************************************************************
//main
int main()
{
	Infile_t Infile;
	Outfile_t Outfile;
	cAccountList ACCOUNT;
	ACCOUNT.load_data(Infile);
	ACCOUNT.sort_by_ID();
	ACCOUNT.print_to_outfile(Outfile);
	ACCOUNT.print_to_screen();
return 0;
}//end main
//*********************************************************************************************************

that worked but now I am getting a whole slew of new errors when I try to compile the same code on my home ubuntu machine

here are the new compiler errors:

assign6.cpp: In member function ‘char cAccount::get_accountName(char (&)[15])’:
assign6.cpp:24: error: ‘strcpy’ was not declared in this scope

So where is strcpy() defined?

assign6.cpp: In member function ‘void cAccountList::print_to_screen()’:
assign6.cpp:104: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

assign6.cpp: In member function ‘bool cAccountList::search()’:
assign6.cpp:148: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

Check your notes...

And look at your lines like this:

if(choice_2=="ID")

That does not do what you want it to. choice_2 is a char array based string (C- style) so you cannot use the equality operator, you must use the strcmp( ) here as well.

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.