Hi. Can someone explain why this isn't working?
#include <iostream>
#include <list>
#include <string>
#include <iomanip>
using namespace std;
/**
* Global Variables
*/
int printer;
int disk;
int cd;
int num;
int pmem, plen;
int dmem, dlen;
int cmem, clen;
class PCB
{
public:
PCB() : pid( 0 ), memoryLocation( 0 ), fileLen( 0 ) { }
void setPid( int p );
int getPid() const;
int incrementPid();
int decrementPid();
void setMemoryStart( int m );
int getMemoryStart() const;
void setFileLength( int l );
int getFileLength() const;
void runningPrompt();
list<PCB> readyQueue;
private:
int pid;
int memoryLocation;
int fileLen;
};
void PCB::runningPrompt()
{
PCB p1;
cout << "Please enter memory location: " << endl;
cin >> pmem;
p1.setMemoryStart( pmem );
p1.readyQueue.push_back( p1 );
}
void PCB::setPid(int p)
{
pid = p;
}
int PCB::getPid() const
{
return pid;
}
int PCB::incrementPid()
{
pid++;
}
void PCB::setMemoryStart( int m )
{
memoryLocation = m;
}
int PCB::getMemoryStart() const
{
return memoryLocation;
}
void PCB::setFileLength( int l )
{
fileLen = l;
}
int PCB::getFileLength() const
{
return fileLen;
}
int main ()
{
PCB p;
p.runningPrompt();
list<PCB>::iterator g;
for( g = p.readyQueue.begin(); g != p.readyQueue.end(); g++ )
{
cout << *g << endl;
}
return 0;
}
I'm getting the following message regarding this line:
cout << *g << endl;
Error message:
98 C:\...\iterator2.cpp no match for 'operator<<' in 'std::cout << (&g)->std::_List_iterator<_Tp>::operator* [with _Tp = PCB]()'
Thank you.