GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Jun-2005, 17:15
Krandygrl00 Krandygrl00 is offline
Junior Member
 
Join Date: May 2005
Location: chicago, il
Posts: 39
Krandygrl00 is on a distinguished road

Help wit my source code compiler errors


I know its a long code but there are classes that relate to eachother. Problems that i am having are within the Seller class
1. SeqSearch function
2. Operator== overload function(I used this because it thought my compiler error had to do with the == operator)
***Please help Im soooooooo stuck and if you have any suggestions to do this in an easier way please help! thank you

CPP / C++ / C Code:
#include <iostream>
#include <string>
#include <string.h>
#include <cstring>
#include <cassert>
using namespace std;

class User
{
private:
	string firstName;											//stores first name
	string lastName;											//stores last name
	string address;												//stores address
	string userName;											//stores user name
	string password;											//stores users password
	string email;												//stores user email address
public:
	void print()const;											//prints out user information
	void setInfo(string first, string last, string add, string user, string pass, string mail);	//function to set information
	User& setFirstName(string first);							//fucntion to set the first name
	User& setLastName(string last);								//function to set the last name
	User& setAddress(string add);								//fucntion to set the address
	User& setUserName(string user);								//function to set the user name
	User& setPassword(string pass);								//function to set the password
	User& setEmail(string mail);								//function to set the email address
	void getInfo(string& first, string& last, string& add, string& user, string& pass, string& mail); //fumction to return users information
	User(string first = "", string last = "", string add = "", string user = "", string pass = "", string mail = ""); //constructor
};
//-------------------------------------------------------------------------------------------------------------------------------------------------
class Item
{
private:
	string item;												//single item being sold
	string itemInfo;											//info on the single item being sold
	double bid;													//bid from user
public:
	void setInformation(string it, string Info, double bidd);	//function to set item and its info
	void print() const;											//function to output item and info
	Item& setItem(string it);									//function to set the item
	Item& setBid(double bidd);									//set bid high or low
	Item& setItemInfo(string Info);								//function to set item info									
	void getInformation(string& it, string& Info, double& bidd);//function to return item and info
	Item(string it = "", string Info = "", double bidd = 0);	//constructor
	template<class Item>										//boolean bid template
	Item acceptBid(Item x, Item y);
};
//--------------------------------------------------------------------------------------------------------------------------------------------------
class Seller : public User
{
private:
	string payment;												//type of payment
	string storeName;											//name of store item was bought from
	char idNum;													//id number for items
	int maxSize;
	int length;
	string *list;
public:
	void setPayInfo(string pay, string name);					//set pay information
	void print()const;											//print pay information
	Seller& setPayment(string pay);								//set payment type
	Seller& setStoreName(string name);							//set store name
	Seller& setIdNumb(char num);								//set id number
	void getPayInfo(string& pay, string& name);					//get pay information
	Seller(string pay = "", string name = "", int size = 500);//constructor
	void insert(string item, char idNum, string tell);			//add an item to the list
	void remove(const idNum);									//remove an item from the list
	void displayItems() const;									//display the descriptions and id 
	void removeAt(int location);								//removes items at a specific location
	int seqSearch(const char idNum);							//searches for id number
	const Seller& operator==(const Seller&);					//overload the assignmnet operator
};
//--------------------------------------------------------------------------------------------------------------------------------------------------
///////////////////*****FUNCTIONS****/////////////////////////

//////////////////USER CLASS FUNCTIONS////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setLastName(string last)
{
	lastName = last;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setFirstName(string first)
{
	firstName = first;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void User::print()const
{
	cout << "NAME: " << firstName << " " << lastName << endl;
	cout << "ADDRESS: " << address << endl;
	cout << "USER NAME and PASSWORD: " << userName << "		" << password << endl;
	cout << "EMAIL ADDRESS: " << email << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void User::setInfo(string first, string last, string add, string user, string pass, string mail)
{
	firstName = first;
	lastName = last;
	address = add;
	userName = user;
	password = pass;
	email = mail;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void User::getInfo(string& first, string& last, string& add, string& user, string& pass, string& mail)
{
	first = firstName;
	last = lastName;
	add = address;
	user = userName;
	pass = password;
	mail = email;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User::User(string first, string last, string add, string user, string pass, string mail)
{
	firstName = first;
	lastName = last;
	address = add;
	userName = user;
	password = pass;
	email = mail;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setAddress(string add)
{
	address = add;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setUserName(string user)
{
	userName = user;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setPassword(string pass)
{
	password = pass;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
User& User::setEmail(string mail)
{
	email = mail;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////ITEM CLASS FUNCTIONS////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Item& Item::setItem(string it)
{
	item = it;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class Item>											
Item acceptBid(Item x, Item y)
{
	if (x >= y)
		return true;
	else 
		return false;
		cout << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Item& Item::setBid(double bidd)
{
	bid = bidd;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Item::print() const
{
	cout << "ITEM: " << item << " " << "ITEM INFORMATION: " << itemInfo;
	cout << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Item::setInformation(string it, string Info, double bidd)
{
	item = it;
	itemInfo = Info;
	bid = bidd;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Item::getInformation(string& it, string& Info, double& bidd)
{
	it = item;
	Info = itemInfo;
	bidd = bid;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Item::Item(string it, string Info, double bidd)
{
	item = it;
	itemInfo = Info;
	bid = bidd;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Item& Item::setItemInfo(string Info)
{
	itemInfo = Info;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////SELLER CLASS FUNCTIONS////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Seller& Seller::setPayment(string pay)
{
	payment = pay;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::print()const
{
	cout << "METHOD of PAYMENT: " << payment;
	cout << endl;
	cout << "STORE NAME: " << storeName;
	cout << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::setPayInfo(string pay, string name)
{
	payment = pay;
	storeName = name;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::getPayInfo(string& pay, string& name)
{
	pay = payment;
	name = storeName;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Seller::Seller(string pay, string name, int size)
{
	payment = pay;
	storeName = name;
	size = size;
	length = 0;

	if(size <= 0)
		maxSize = 500;
	else
		maxSize = size;

	list = new string[maxSize];
	assert(list != NULL);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Seller& Seller::setStoreName(string name)
{
	storeName = name;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Seller& Seller::setIdNumb(char num)
{
	idNum = num;
	return *this;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::displayItems() const
{
	if(length == 0)
		cout << "List is empty." << endl;
	else
	{
		for(int i = 0; i < length; i++)
			cout << list[i] << " ";
		cout << endl;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::insert(string item, char idNum, string tell)
{
	if(length == maxSize)
		cout << "List is full." << endl;
	else
		list[length++] = item;
		list[length++] = idNum;
		list[length++] = tell;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::removeAt(int location)
{
	if(location < 0 || location >= length)
		cerr << "The item is not in the list." << endl;
	else
	{
		for(int i = location; i < length - 1; i++)
			list[i] = list[i + 1];
		length--;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Seller::remove(const idNum)
{
	int loc;

	if(length == 0)
		cerr << "Empty list." << endl;
	else 
	{
		loc = seqSearch(idNum);

		if(loc != -1)
			removeAt(loc);
		else
			cout << "Item not in list." << endl;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Seller::seqSearch(const char idNum)
{
	int loc;
	bool found = false;

	for(loc = 0; loc < length; loc++)
		if(list[loc] == idNum)
		{
			found = true;
			break;
		}
		if(found)
			return loc;
		else
			return -1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const Seller& Seller::operator ==(const Seller& otherList)
{
	if(this != &otherList)
	{
		delete [] list;
		maxSize = otherList.maxSize;
		length = otherList.length;

		list = new Seller[maxSize];
		assert(list != NULL);

		for(int i = 0; i < length; i++)
			list[i] = otherList.list[i];
	}
	return *this;

}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	char ans;
	int idNum;
	string tell;
	string item;
	Seller list;

	cout << "This Is An Online Auction Site!" << endl;
	cout << endl;
	
/*	User use1("Kandice", "Golar", "1234 S. Me St.  Ogden, UT.", "Krandygrl00", "soccer", "KandiceGolar@mail.weber.edu");
	User use2("Cyle", "Burgess", "567 S 890 W  Salt Lake City, UT.", "FightMe1", "NHB666", "CyleB@slc.edu");

	Item it1("IPOD shuffle", "lets you download more than 800 songs, light weight and durable", 105.00);
	Item it2("Nike Shocks", "Light Blue and Gray, comfortable, a good running shoe", 135.80);

	Seller sell1("Check", "Best Buy");
	Seller sell2("Master Card", "Nike Outlet Chicago");
	Seller sell3;

	use1.print(); cout << endl;				//print user1 info
	use2.print(); cout << endl;				//print user2 info
	cout << endl;

	it1.print(); cout << endl;				//print item1 info
	it2.print(); cout << endl;				//print item2 info
	cout << endl;

	sell1.print(); cout << endl;			//print Payment and store 1
	sell2.print(); cout << endl;			//print payment and store 2
	cout << endl;

	cout << "If bid = 0 then you have not raised the bid.  If bid = 1 your bid is accepted as the highest bid." << endl;
	cout << "Nike Shocks bid.  You bid $105.00:  ";
	cout << acceptBid(105.00, 145.88);
	cout << endl;
	cout << "IPOD shuffle bid.  You bid $135.80:  ";
	cout << acceptBid(135.80, 100.99);
	cout << endl;
	cout << endl;*/

	do{
	cout << "Please enter an Item: ";
	cin >> item;
	cout << endl;
	cout << "Desctiption: ";
	cin >> tell;
	cout << endl;
	cout << "Id Number: ";
	cin >> idNum;
	cout << endl;
	cout << "Enter another Item(y/n)?: ";
	cin >> ans;
	list.insert(item, idNum, tell);							//enters item and its information into the array
	}while(ans != 'n');

	cout << "The item(s) that you have enter are: ";		//dispays the items in the array
	list.displayItems();
	cout << endl;
	cout << "Please enter the Id Number of the item to be removed: ";
	cin >> idNum;
	list.remove(idNum);										//removes an item by its id number
	cout << "The list is now..";
	list.displayItems();
	return 0;
}
Last edited by LuciWiz : 06-Jun-2005 at 00:03. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 06-Jun-2005, 08:14
Kacyndra's Avatar
Kacyndra Kacyndra is offline
Member
 
Join Date: May 2005
Location: Maryland
Posts: 226
Kacyndra will become famous soon enough
hi,
can you also post the error messages that you are getting here?
__________________
Xrum!
 
 

Recent GIDBlogObservations of Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Guidelines for posting requests for help - UPDATED! WaltP C++ Forum 1 22-Aug-2008 00:07
C++ PhoneBook marita C++ Forum 46 12-Jun-2005 12:10
Having a problem Chuckles Computer Hardware Forum 19 13-Sep-2004 12:17
Windows 2000 & NT source code leak Garth Farley Computer Software Forum - Windows 3 26-Feb-2004 15:23
web server in secure mode not connecting to http application tcsasp Apache Web Server Forum 0 06-Nov-2003 00:08

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:51.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.