Monday, April 28, 2014

error while using the function size ()

Newsgroup: comp.lang.c++

Subject: error while using the function size ()

From: Milica Milojevic <milicam363@...>

Date: Mon, 28 Apr 2014 04:09:11 -0700 (PDT)



Hi,



I have created a list called measuresQueue (list<pssMeasure *> measuresQueue; ) which is consisted of ten elements. Then I used measuresQueue.size() function. When I did the printf of the previous function it prints me the number four not ten. Can someone help me with this problem.



Here is my code:



In for loop I have entered my elements of the list:



for (filtertime_t=0; filtertime_t<=1.8; filtertime_t=filtertime_t+0.2) {



pssMeasure *mes = measureReceived(filtertime_t,y,mes_vect,mes_cov);

y++;



process_th->critical_section->writeMeasures(mes);



}

Here it is the measureReceived function description:

pssMeasure * measureReceived(double timeStamp,int j,double array[3][10], double array_cov[3]) {





pssMeasure *mes = new pssMeasure();





mes->track_id =7;

mes->timeStamp =timeStamp;



for (int i=0; i<3; i++)

{

mes->z_t[i]=array[i][j];



}





for(int i = 0; i < 3; i++) {



for(int k = 0; k < 3; k++)

mes->cov_z[i][k] = 0.0;



mes->cov_z[i][i] = array_cov[i];





}

return mes;

}

After creating mes I store them using the function writeMeasures:



void CPSSCriticalSection::writeMeasures(pssMeasure* pss_mes) {



measuresQueue.push_back(pss_mes);}



In order to check that my all elements are stored in the measuresQueue list I have used this after the measuresQueue.push_back(pss_mes);



cout << "hello1" << endl

printf("%f %f %f %f \n", pss_mes->timeStamp, pss_mes->z_t[0], pss_mes->z_t[1], pss_mes->z_t[2]);



Everything was fine until I wanted to see the size of my list measuresQueue with the: cout << "measuresQueue. size: " << measuresQueue.size() << '\n';



I always get the number 4 instead of ten. I don't know what is the reason?











Thank you,

M.













via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1pHsde9

View all the progranning help forums at:

http://ift.tt/1dP9txN

No comments:

Post a Comment