| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"" |
| Date: |
18 Nov 2004 05:43:44 PM |
| Object: |
typedef'd return type for a template class member function |
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
.
|
|
| User: "Victor Bazarov" |
|
| Title: Re: typedef'd return type for a template class member function |
18 Nov 2004 05:45:14 PM |
|
|
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
.
|
|
|
| User: "" |
|
| Title: Re: typedef'd return type for a template class member function |
18 Nov 2004 05:53:16 PM |
|
|
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.
.
|
|
|
| User: "Victor Bazarov" |
|
| Title: Re: typedef'd return type for a template class member function |
18 Nov 2004 06:10:01 PM |
|
|
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
.
|
|
|
|
|
|

|
Related Articles |
|
|