Advertisement

03.28.2008 at 04:32AM PDT, ID: 23276829
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

Converting VC7 to VC8 regarding using iterators as pointers

Asked by stefanlennerbrant in Microsoft Visual C++.Net, Windows MFC Programming

Tags: , , ,

I'm porting a project from VC7 to VC8 and thus run into problems with using const_iterators as pointers (allowed in VC7 but allowed in VC8)

For instance, I've got a std::list (accessed via a const_iterator) that contains a number of objects, Assume it's descriptions of different cars.

Now, I need to print/output all the cars that follow after one specific car in the list. To do this, I've got a function that finds a specific car in the list, and returns a reference to it. The calling function can then start outputting the remainder of the list.

I've got a CCarList class that contains the actual list, providing Begin() and End() methods that map to the normal begin() and end().
The TCarIterator is not (as of now) a class, but merely a typedef for a const_iterator of CCarList

The "find" function looks like this. It returns true/false if the searched car was found. If found, the FoundIt iterator input variable is set to the found car -- the calling function may the begin iterating through the rest of the list.
This works very well in VC7 but I suppose I get problems in VC8?

bool CMain::Find(CCarList *pList, TCarIterator &FoundIt, CString sName) {
   bool bFound = false;
   for (TCarIterator cit = pList->Begin(); !bFound && cit != pList->End(); cit++) {
      if ((*cit)->Name() == sName) {
        bFound = true;
        FoundIt = cit;
     }
   }

   return bFound;
}

1)
Can I do this in VC8? Is it possible to return a pointer to a "specific point" in the list, as identified by a const_iterator?

2)
Also, in other parts of the application, I compare a TCarIterator variable with another, to see if they point to the exakt same object in a list. I suppose that this is not possible in VC8 as well?

3)
Sometimes I set a TCarIterator variable to NULL, to indicate that it's not yet set to an object in a list (not "initiated")
I could check for "==end()" instead, but I suppose that this is linked to any potential problems with issue 1) above?

Any ideas on this?
Thanks
/Stefan LennerbrantStart Free Trial
[+][-]03.28.2008 at 05:55AM PDT, ID: 21229881

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.28.2008 at 09:41AM PDT, ID: 21231952

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 07:04PM PDT, ID: 21657220

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 08:01PM PDT, ID: 21657411

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.01.2008 at 06:41AM PDT, ID: 21687076

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.10.2008 at 04:18AM PDT, ID: 21750058

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.11.2008 at 06:15PM PDT, ID: 21987163

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.16.2008 at 08:22PM PDT, ID: 22022109

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C++.Net, Windows MFC Programming
Tags: VC8, const_iterator, pointer, compatibility problem
Sign Up Now!
Solution Provided By: Computer101
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906