Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > typedef'd return type for a template class member function

Reply
Thread Tools

typedef'd return type for a template class member function

 
 
david.corby@gmail.com
Guest
Posts: n/a
 
      11-18-2004
Hi again everyone!

I was wondering if there is any way to specify a return type for a
template class member function that is typedef'd in the class. I.E...

template <class T> class A {

public:

typedef int TD;

private:

TD b ();

};

template <class T> A<T>::TD b () {

// Do stuff.

}

I know this won't compile, but hopefully you can see what I'm trying to
do. The type TD will only be used in-class. I know I can stick the
typedef outside of the class, but I'd like to not pollute that
namespace.

Is there any way to make this work? I'm fairly certain I've done it on
non-templated classes.

Thanks!
Dave Corby

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      11-18-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I was wondering if there is any way to specify a return type for a
> template class member function that is typedef'd in the class. I.E...
>
> template <class T> class A {
>
> public:
>
> typedef int TD;
>
> private:
>
> TD b ();
>
> };
>
> template <class T> A<T>::TD b () {


template<class T> A<T>::TD A<T>::b() {

>
> // Do stuff.
>
> }
>
> I know this won't compile, but hopefully you can see what I'm trying to
> do. The type TD will only be used in-class. I know I can stick the
> typedef outside of the class, but I'd like to not pollute that
> namespace.
>
> Is there any way to make this work? I'm fairly certain I've done it on
> non-templated classes.


'b'a is a member, you need to qualify the name.

V
 
Reply With Quote
 
 
 
 
david.corby@gmail.com
Guest
Posts: n/a
 
      11-18-2004
Oops... yes, of course, my definition was:

template <class T> A<T>::TD A<T>::b () {

// Do stuff.
}

My mistake, but I didn't make it in the case I'm asking about.

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      11-19-2004
(E-Mail Removed) wrote:
> Oops... yes, of course, my definition was:
>
> template <class T> A<T>::TD A<T>::b () {
>
> // Do stuff.
> }
>
> My mistake, but I didn't make it in the case I'm asking about.
>


Now, it's a good time to correct your mistake and post the real code
that doesn't work.

V
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class nested inside a template class as template function argument type claudiu C++ 3 04-01-2011 01:02 PM
Class nested inside a template class as template function argument type claudiu C Programming 2 04-01-2011 12:10 PM
How to use the template member function of a template in the memberfunction of another template class? Peng Yu C++ 3 10-26-2008 03:51 PM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
typedef'd return type of a template class member function: take 2 Pete Becker C++ 5 11-19-2004 12:50 AM



Advertisments