Re: Why does this fail to compile?
Re: Why does this fail to compile?
- Subject: Re: Why does this fail to compile?
- From: "Jason Foreman" <email@hidden>
- Date: Fri, 16 Nov 2007 09:08:45 -0600
On 11/16/07, Jamie Cho <email@hidden> wrote:
compile the code below, I get the following errors from XCode 3.0:
/Users/jcho/CompilingProblem/Vector.h: In member function 'std::string
jcho::Vector<T>::to_string() const':
/Users/jcho/CompilingProblem/Vector.h:31: error: expected `;' before
'iter'
/Users/jcho/CompilingProblem/Vector.h:32: error: 'iter' was not
declared in this scope
This problem only happens when Vector is a template class. What am I
doing wrong?
Read up on the "typename" keyword.
vector_t::const_iterator iter = _storage.begin();
In this case, vector_t::const_iterator is a dependent type, so you should use this:
typename vector_t::const_iterator iter = _storage.begin();
Hope that helps,
Jason
_______________________________________________
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