Click here to Skip to main content
15,878,543 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: problem with std::vector Pin
erfi20-Sep-06 23:41
erfi20-Sep-06 23:41 
GeneralRe: problem with std::vector Pin
Christian Graus21-Sep-06 0:16
protectorChristian Graus21-Sep-06 0:16 
GeneralRe: problem with std::vector Pin
prasad_som21-Sep-06 0:42
prasad_som21-Sep-06 0:42 
GeneralRe: problem with std::vector Pin
erfi21-Sep-06 1:08
erfi21-Sep-06 1:08 
QuestionRe: problem with std::vector Pin
prasad_som21-Sep-06 0:49
prasad_som21-Sep-06 0:49 
AnswerRe: problem with std::vector Pin
Mr.Brainley21-Sep-06 1:16
Mr.Brainley21-Sep-06 1:16 
GeneralRe: problem with std::vector Pin
prasad_som21-Sep-06 1:28
prasad_som21-Sep-06 1:28 
GeneralRe: problem with std::vector [modified] Pin
Zac Howland21-Sep-06 3:34
Zac Howland21-Sep-06 3:34 
prasad_som wrote:
But in given code , that doesn't matter.
As revealed later, it was initializatin problem.


Actually, he probably would have caught it sooner because I'm guessing it was something like this:

void CQMDlg::OnGetvarCountButton() 
{
     varCount = -1; // just as an example
     for(int i=0; i!=varCount; ++i)    
     {
	intVec.push_back(i);
     }
}


Which will run forever, whereas if the code was written as:

void CQMDlg::OnGetvarCountButton() 
{
     varCount = -1; // just as an example
     for(int i=0; i<varCount; ++i)    
     {
	intVec.push_back(i);
     }
}


It would have been caught immediately since the vector would have been empty.

As a side note, STL's iterators use != for a reason. For most of the containers, there is no guarantee that the memory locations are sequential, so you can't do a < comparison to find the end of the loop.


-- modified at 10:18 Thursday 21st September, 2006

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: problem with std::vector Pin
prasad_som21-Sep-06 3:48
prasad_som21-Sep-06 3:48 
QuestionPopulating a ComboBox Pin
namy3120-Sep-06 23:13
namy3120-Sep-06 23:13 
QuestionRe: Populating a ComboBox Pin
prasad_som20-Sep-06 23:36
prasad_som20-Sep-06 23:36 
AnswerRe: Populating a ComboBox Pin
namy121-Sep-06 2:30
namy121-Sep-06 2:30 
AnswerRe: Populating a ComboBox Pin
Hamid_RT21-Sep-06 0:17
Hamid_RT21-Sep-06 0:17 
GeneralRe: Populating a ComboBox Pin
namy121-Sep-06 2:33
namy121-Sep-06 2:33 
GeneralRe: Populating a ComboBox Pin
prasad_som21-Sep-06 3:01
prasad_som21-Sep-06 3:01 
GeneralRe: Populating a ComboBox Pin
Hamid_RT21-Sep-06 8:31
Hamid_RT21-Sep-06 8:31 
AnswerRe: Populating a ComboBox Pin
prasad_som21-Sep-06 3:03
prasad_som21-Sep-06 3:03 
GeneralRe: Populating a ComboBox Pin
David Crow21-Sep-06 3:35
David Crow21-Sep-06 3:35 
GeneralRe: Populating a ComboBox Pin
prasad_som21-Sep-06 3:46
prasad_som21-Sep-06 3:46 
GeneralRe: Populating a ComboBox Pin
David Crow21-Sep-06 4:22
David Crow21-Sep-06 4:22 
GeneralRe: Populating a ComboBox Pin
prasad_som21-Sep-06 19:11
prasad_som21-Sep-06 19:11 
QuestionRe: Populating a ComboBox Pin
David Crow21-Sep-06 3:36
David Crow21-Sep-06 3:36 
AnswerRe: Populating a ComboBox Pin
namy121-Sep-06 18:19
namy121-Sep-06 18:19 
QuestionRe: Populating a ComboBox Pin
David Crow22-Sep-06 3:18
David Crow22-Sep-06 3:18 
AnswerRe: Populating a ComboBox Pin
namy124-Sep-06 18:58
namy124-Sep-06 18:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.