![]() |
template class
template<typename T>
class TestCase: public MyClass { public: int stringLength; vector<T> String; vector<T>::iterator i; } why the above cannot be compiled, gcc reporting the error: xx.h:53: error: type ‘std::vector<T, std::allocator<_CharT> >’ is not derived from type ‘TestCase<T>’ xx.h:53: error: expected ‘;’ before ‘i’ But the following can be compiled, any one can give a reason or reference? class TestCase: public MyClass { public: int stringLength; vector<T> String; typename vector<T>::iterator i; } |
Re: template class
On May 14, 7:44*pm, Qian Xin <chians...@gmail.com> wrote:
> template<typename T> > class TestCase: public MyClass > { > public: > > * * int stringLength; > * * vector<T> String; > * * vector<T>::iterator i; > > } > > why the above cannot be compiled, gcc reporting the error: > xx.h:53: error: type ‘std::vector<T, std::allocator<_CharT> >’ is not > derived from type ‘TestCase<T>’ > xx.h:53: error: expected ‘;’ before ‘i’ > > But the following can be compiled, any one can give a reason or > reference? > > class TestCase: public MyClass > { > public: > > * * int stringLength; > * * vector<T> String; > * * typename vector<T>::iterator i; > > > > > > > > } sorry, I have found the answer: http://blogs.msdn.com/b/slippman/arc...11/212768.aspx |
Re: template class
Qian Xin wrote:
> template<typename T> > class TestCase: public MyClass > { > public: > > int stringLength; > vector<T> String; > vector<T>::iterator i; > } > > why the above cannot be compiled, gcc reporting the error: > xx.h:53: error: type ‘std::vector<T, std::allocator<_CharT> >’ is not > derived from type ‘TestCase<T>’ > xx.h:53: error: expected ‘;’ before ‘i’ > > But the following can be compiled, any one can give a reason or > reference? > > class TestCase: public MyClass > { > public: > > int stringLength; > vector<T> String; > typename vector<T>::iterator i; > } See http://stackoverflow.com/questions/5...d-typename-in- templates/5581807#5581807 |
Re: template class
Qian Xin <chianshin@gmail.com> wrote:
> any one can give a reason The standard says so. |
| All times are GMT. The time now is 05:34 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.