Re: class member types

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 04/01/04


Date: Thu, 01 Apr 2004 02:32:45 GMT


"nospam" <johnnynoname_1@hotmail.com> wrote...
> If i have some code like this:
>
> template<typename T>
> class eg
> {
> public:
> typedef T size_type;
> ...
> void somefunc(size_type);
> };
>
> What would be the correct way to define this
> member function outside of the class definition?
>
> template<typename T>
> void eg<T>::somefunc(size_type)
> {}
>
> The above code compiles, but is it correct?

Yes. Parameter types are look up in the scope of the class for
which you define the member. Since you've already written
'eg<T>' once (just before the '::'), you don't need to write it
again.

> Or do i need to do something like:
>
> template<typename T>
> void eg<T>::somefunc(typename eg<T>::size_type)
> {}

Shouldn't have to.

Victor



Relevant Pages

  • Re: invalid access to non-static data member
    ... >I'd like to be able to evaluate this macro outside of the scope (or do I ... just make a public member function which returns either ... of them are null pointers. ... much overhead; of course, since each object has its own vector, then ...
    (comp.lang.cpp)
  • Re: invalid access to non-static data member
    ... >>Is gcc right to complain? ... I thought arguments to sizeof are not evaluated. ... I'd like to be able to evaluate this macro outside of the scope (or do I ... > gives you the sizemember function for free, ...
    (comp.lang.cpp)
  • Re: Gloox
    ... In member function 'virtual int ... this scope ... connectiontcpbase.cpp: In member function 'virtual const std::string ... Did any ported Gloox to Os/2? ...
    (comp.os.os2.programmer.porting)
  • Re: How is the concept of scope implemented?
    ... The same way as for C -a tree of stacks. ... The scope in which you are ... used to call a member function is represented by an implicit pointer ... that kind of stuff: RTTI, exceptions, templates. ...
    (comp.compilers)
  • Qt4: Help, can not install or update any QT lib/app anymore!
    ... on a very 'production'-sensitive box I get an error whenever I try to install any qt4-related application or library. ... ../../corelib/io/qfsfileengine.cpp: In member function 'bool ... declared in this scope ... *** Error code 1 ...
    (freebsd-questions)