pointer automatically copying other pointer's info
<p>The problem I am having, which I hope someone maybe have had before - I have so many files and classes in this project that I didn't want to have to put them all on the website here so I consolidated what i called Ready_Queue's methods to if statements down below. Now when I run the iteration once it has no problem. PCB(an object) * front receives the correct memory address. Now if i go through a second time, front even though it should not gets the address of the new object along with * rear as well, and so on for all next iterations of the loop front keeps getting reassigned to the next object that should be added to list when it should be rear. I tested this logic that i have when using the Ready_Queue and it works, its just for some reason in this loop front keeps getting reassigned. I know this is a lot to look at and ask so if you have the spare time or just have a similar problem in the past let me know, 
Thanks in advance.</p>

<pre><code>for(int i = 0; i &lt; filecount; i++)
    {

    token = filelist[i];
    found = token.find(" ");          
    found = token.find(" ",found+1);
    firstspace = int(found); 
    found = token.find(" ",firstspace+1);
    secondspace = int(found);
    int len = secondspace - firstspace;
    string arrival = token.substr(firstspace,len);          
    arrival_time = atoi(arrival.c_str());          
    //cout &lt;&lt; arrival_time &lt;&lt; endl;
    if (arrival_time == globaltime)
    {
        //cout &lt;&lt; i &lt;&lt; endl;
        arrivalproc.push(i);
        count++;
       //cout &lt;&lt; arrivalproc.hSize() &lt;&lt; endl;
         //cout &lt;&lt; count &lt;&lt; endl;

    }
        //cout &lt;&lt; i &lt;&lt; endl;    

    }
   // arrivalproc.show();

    while (arrivalproc.hSize() &gt; 0) 

    {


        if (idnumbers.hSize() &gt; 0)
        {    
            //idnumbers.show();





        PCB obj;    
        string temp1 = filelist[arrivalproc.pop()];
        istringstream iss(temp1);
        //idnumbers.show();
        spot = idnumbers.pop();
            //count++;

            cout &lt;&lt; spot &lt;&lt; endl;

        getline (iss,token,' ');                
       // cout &lt;&lt; "Name contains: " &lt;&lt; token &lt;&lt; "\n";
        obj.setName(token);

        getline (iss,token, ' '); 
        //cout &lt;&lt; "token contains: " &lt;&lt; token &lt;&lt; "\n";     
        int prio = atoi(token.c_str());      
        obj.setPriority(prio);

        getline (iss,token, ' '); 
        //cout &lt;&lt; "token contains: " &lt;&lt; token &lt;&lt; "\n";     
        int arrival = atoi(token.c_str());      
        obj.setArrival(arrival);



        char status = 'r';
        obj.setStatus(status);

        getline (iss,token, ' ');          
        int time = atoi(token.c_str());
        obj.setCPUtime(time);


        RegisterSet set;      

        getline (iss,token, ' ');
       // cout &lt;&lt; "XARtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        string temptok = token.data();
        int temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n";         
        set.setXAR(temp);
        //int test = set.getXAR();
        //cout &lt;&lt; "test = " &lt;&lt; test &lt;&lt; "\n";

        getline (iss,token, ' ');
      //  cout &lt;&lt; "XDItoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setXDI(temp);

        getline (iss,token, ' ');
      //  cout &lt;&lt; "XDOtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "XDO contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setXDO(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "PCtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "PC contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setPC(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "IRtoken contains: " &lt;&lt; token.data() &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n";     
        set.setIR(temp);
        //int test = set.getIR();
        //cout &lt;&lt; "test = " &lt;&lt; test &lt;&lt; "\n";

        getline (iss,token, ' ');
        //cout &lt;&lt; "EMITtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setEMIT(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "RRtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setRR(temp);

        getline (iss,token, ' ');
       // cout &lt;&lt; "PSWtoken contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setPSW(temp);

        getline (iss,token, ' ');
       // cout &lt;&lt; "R0token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        //int test = set.getR0();
        //cout &lt;&lt; "test = " &lt;&lt; test &lt;&lt; "\n";  
        set.setR0(temp);

        getline (iss,token, ' ');
       // cout &lt;&lt; "R1token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR1(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "R2token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();      
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR2(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "R3token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR3(temp);

        getline (iss,token, ' ');
       // cout &lt;&lt; "R4token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR4(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "R5token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "R5 contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR5(temp);

        getline (iss,token, ' ');
       // cout &lt;&lt; "R6token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
       // cout &lt;&lt; "R6 contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR6(temp);

        getline (iss,token, ' ');
        //cout &lt;&lt; "R7token contains: " &lt;&lt; token &lt;&lt; "\n";
        temptok = token.data();
        temp = set.HexConverter(temptok);
        //cout &lt;&lt; "int contains: " &lt;&lt; temp &lt;&lt; "\n"; 
        set.setR7(temp);          



        obj.setRegisters(set);      

        //PROBLEM OCCURS HERE SOME HOW THE FRONT OF RQ GET ASSIGNED THE NEW OBJ AND GETS       RID OF WHAT WAS THERE BEFOR.    
        obj.setID(spot);
        rq.addReadyP(obj);
        list[spot] = obj;
        PCB * tempoint;
            tempoint = &amp;obj;    
        if(rqsize == 0)
        {
            front = &amp;obj;
            rqsize++;
        }
        else if(rqsize == 1)
        {
            front-&gt;setNext(tempoint);
            rear = &amp;obj;
            rqsize++;
        }
        else
        {
            rear-&gt;setNext(tempoint);
            rear = &amp;obj;
            rqsize++;

        }
</code></pre>

<p>Here is the code for Ready_Queue as you can see i just Implemented it as a series of if statements in the main and i get the same problem.</p>

<pre><code>Ready_Queue::Ready_Queue()
{
   tempfront = NULL; 
   front = NULL;
   rear= NULL;
   size = 0;

}
PCB* Ready_Queue::getReadyP()
{


    if (size == 1)
    {
    PCB * temp;    
    temp = front;   
        size--;   

    return temp;



    }
       else
    {
        PCB * temp;    
        temp = front;   

        front = front-&gt;getNext();
        //cout &lt;&lt; front-&gt;getID() &lt;&lt; endl;




        size--;
        return temp; 





    }

}
void Ready_Queue::addReadyP(PCB a)
{



    tempfront = &amp;a;    

    if (size == 0) 
    {

      front = tempfront;
        cout &lt;&lt; "FRONT POINT SET TO GIVEN" &lt;&lt; endl;





       size++;

    }
    else if (size == 1)
    {
        //cout &lt;&lt; front-&gt;getID() &lt;&lt; "FRONTID IS" &lt;&lt; endl; 
        front-&gt;setNext(tempfront);
        rear = tempfront;
        cout &lt;&lt; "SET FRONT NEXT AND REAR SET TO GIVEN" &lt;&lt; endl;
        size++;

    }
    else
    {
      rear-&gt;setNext(tempfront);
      rear = tempfront;
      //cout &lt;&lt; mypointer-&gt;getID() &lt;&lt; endl;

      size++;  
    }

}
int Ready_Queue::getSize()
{
    return size;
}
</code></pre>
