Dear Sir!
Please copy the following code into a C++ CLR project and add a breakpoint in the Contains() method. Then step through the code and note how the cursor jumps between the lines.
It seams that the code is executed correctly, but the cursor feedback really does not make much sense. The cursor jumps back and forth somewhat unrelated to the source code logic.
Kind regards
Dag Sanna
<Code start>
#include
"stdafx.h"#include
<string>#include
<vector>using
namespace System;class
StringList{
private:std::vector<std::string*>* mStringList;
public:StringList()
{
mStringList =
new std::vector<std::string*>();}
int StringList::AddText(std::string* aText){
// Check if the text already exists if (Contains(aText)) return 1;mStringList->push_back(aText);
return 0;}
bool StringList::Contains(std::string* aText){
printf(
"Line1\n");std::vector<std::string*>::iterator iter;
printf(
"Line3\n"); for ( iter = mStringList->begin(); iter != mStringList->end(); iter++ ){
printf(
"Line6\n"); if ( !(*iter)->compare(*aText) ){
printf(
"Line9\n"); return true;}
printf(
"Line12\n");}
printf(
"Line14\n"); return false;}
};
int
main(array<System::String ^> ^args){
StringList* sl =
new StringList();sl->AddText(
new std::string("Text1"));sl->AddText(
new std::string("Text2"));sl->AddText(
new std::string("Text3"));sl->AddText(
new std::string("Text2"));sl->AddText(
new std::string("Text4"));Console::WriteLine(L
"Hello World"); return 0;}
<Code end>

Strange behaviour when stepping through CLR code