• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Compile error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compile error


  • Subject: Re: Compile error
  • From: Olivier Tristan <email@hidden>
  • Date: Wed, 07 Jun 2006 16:40:34 +0200

vrishba wrote:
The same piece of code builds & runs well in Visual
C++.
So that's why i thought it's XCode/gcc related.

In that case it should be related to the use of the mandatory typename keyword when referring to type in template class.


Something like that should compile. I didn't test however.

#include <vector>

template<class T> class MyVector : public
std::vector<T> {

public:
bool contains(T object) {
typedef typename std::vector<T>::iterator Iterator;
Iterator i;


   i=this->begin();
   while(i!=this->end()) {
     if (object==*i) return(true);
     i++;
   }
   return(false);
 }
};


A better solution would be to use std::find in <algorithm>

Hope this helps.


-- Olivier Tristan Ultimate Sound Bank

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Compile error
      • From: vrishba <email@hidden>
References: 
 >Re: Compile error (From: vrishba <email@hidden>)

  • Prev by Date: Re: Compile error
  • Next by Date: Re: Debugging dreams?
  • Previous by thread: Re: Compile error
  • Next by thread: Re: Compile error
  • Index(es):
    • Date
    • Thread