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.

remove the asterisk

Thanks Ancient Dragon.

I did and I still get the error message:

cout << g << endl;

Error message:

98 C:\...\iterator2.cpp no match for 'operator<<' in 'std::cout << g' 

That's because g points to an entire class and you need a friend class that prints all of it. cout has no idea how to display the class.

Thanks. Yes, I can see that.

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.