hello I wrote this code and i'm having some trubble with it. When i debugg my code i get a bunch of these errors.
c:\users\roxxi\documents\visual studio 2010\projects\lab3\main.cpp(33): error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(679): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
both me, my proff. my mom a programmer couldnt find the problem if someone see's the problem can you please help me
my code has three files a .h .cpp and main.cpp
//unsorted.h
// MAX_ITEMS: the maximum number of items on the list
#include <fstream>
#include <string>
#include <cctype>
#include <cstring>
#include <iostream>
using namespace std;
int const MAX_ITEMS = 1000;
class UnsortedType
{
public:
UnsortedType();
void MakeEmpty();
bool IsFull() const;
int GetLength() const;
void RetrieveItem(int& item, bool& found);
void InsertItem(int item);
void DeleteItem(int item);
void DeleteItemAll(int item);
void ResetList();
void GetNextItem(int& item);
private:
int length;
int info[MAX_ITEMS];
int currentPos;
};
Unsorted.cpp
#include "unsorted.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cctype>
#include <cstring>
using namespace std;
UnsortedType::UnsortedType()
{
length = 0;
}
bool UnsortedType::IsFull() const
{
return (length == MAX_ITEMS);
}
void UnsortedType::MakeEmpty()
{
length = 0;
}
int UnsortedType::GetLength() const
{
return length;
}
void UnsortedType::RetrieveItem(int& item, bool& found)
{
bool moreToSearch;
int location = 0;
found = false;
moreToSearch = (location < length);
while (moreToSearch && !found)
{
if (item == info[location]){
found = true;
item = info[location];
}
else {
location++;
moreToSearch = (location < length);
}
}
}
void UnsortedType::InsertItem(int item)
// Post: item is in the list.
{
info[length] = item;
length++;
}
void UnsortedType::DeleteItem(int item)
{
int location = 0;
while (item != info[location])
location++;
info[location] = info[length - 1];
length--;
}
void UnsortedType::ResetList()
{
currentPos = -1;
}
void UnsortedType::DeleteItemAll(int item)
{
bool moreToSearch,found;
int location = 0;
found= false;
moreToSearch = (location < length);
while (moreToSearch && !found)
{
if (item == info[location]){
found = true;
item = info[location];
info[location] = info[length - 1];
length--;
}
else
{
location++;
moreToSearch = (location < length);
}
}
}
void UnsortedType::GetNextItem(int& item)
{
currentPos++;
item = info[currentPos];
}
main.cpp
//main.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
#include <cstring>
#include "unsorted.h"
using namespace std;
void PrintList(UnsortedType list);
int main()
{
string outputLabel;
string command; // operation to be executed
ofstream outFile;
int number;
int item;
UnsortedType list;
bool found;
int numCommands;
outFile.open("data.out");
cout<<"Input a command or quit to terminate the test"<<endl;
cin >> command;
numCommands = 0;
while (command != "Quit")
{
if (command == "InsertItem")
{
cin >> number;
item=number;
list.InsertItem(item);
outFile<<command<<" : is inserted"<< list.InsertItem(item)<<endl;
cout<<item;
cout << " is inserted" << endl;
}
else if (command == "DeleteItem")
{
cin >> number;
item=number;
list.DeleteItem(item);
cout<<item;
outFile<<command << " is deleted" <<list.DeleteItem(item)<< endl;
}
else if (command == "RetrieveItem")
{
cin >> number;
item=number;
list.RetrieveItem(item, found);
if (found)
outFile<< command<< number << " found in list." <<list.RetrieveItem(item,found)<< endl;
else outFile << number << " not in list." <<list.RetrieveItem(item,found) << endl;
}
else if (command == "LengthIs")
outFile<<command << "Length is " << list.GetLength() << endl;
else if (command == "IsFull")
if (list.IsFull())
outFile<<command << "List is full." <<list.IsFull()<< endl;
else outFile<<command << "List is not full." <<list.IsFull() << endl;
else PrintList(list);
numCommands++;
outFile<<command << " Command number " << numCommands << " completed." <<list.ResetList()
<< endl;
cin >> command;
};
cout << "Testing completed." << endl;
return 0;
}
void PrintList(UnsortedType list)
// Pre: list has been initialized.
// dataFile is open for writing.
// Post: Each component in list has been written to dataFile.
// dataFile is still open.
{
int length;
int item;
list.ResetList();
length = list.GetLength();
for (int counter = 1; counter <= length; counter++)
{
list.GetNextItem(item);
cout<<item;
}
outFile.close();
}
outFile<<command<<" : is inserted"<< list.InsertItem(item)<<endl;