am trying to get uniqueID in the following segment of code to count how many times the if statement gets used, but all i get is a list of 1's. Any ideas??

if (is_tri == true) {
    //add the triangle to the list
    unsigned int uniqueID = 0;
    uniqueID++;
    cout<< uniqueID << " ";
    triangle d_tri(uniqueID, (*nodeVec[i]), (*nodeVec[j]),    (*nodeVec[k]));
    ListElement *p = new triangle(d_tri);
    triList.AddElement(p);
}

Recommended Answers

All 2 Replies

Hi there! The answer is simple; Don't initiate uniqueID several times! Try moving unsigned int uniqueID = 0; to outside of your loop, or pass it as an argument if you are using recursion!

Good luck!
Emil Olofsson

Of course! What a silly error...

Thanks!

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.