473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

Jul 22 '05 #1
3 1790
da*********@gmail.com 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
Jul 22 '05 #2
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.

Jul 22 '05 #3
da*********@gmail.com 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
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roger Leigh | last post by:
Although I've got over most of my template-related problems, I'm having trouble when I started to use default template parameters. For template type T, I've typedef'd this as object_type and then...
2
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't...
11
by: cppaddict | last post by:
Hi, I recently started using typedefs and am curious if they are ever considered evil. In particular, I'm thinking of a situation where a typedef is used in a file but defined in another,...
2
by: marco | last post by:
the problem: I use a typedef inside a class template, than I use this type (dim_v<N1>::Type) to define the argument of a template function f but when I call this function from main, the compiler...
5
by: Dave | last post by:
The following code won't compile for me, it does not recognize my typedef'd type as a type: template <class T> class A { public: typedef int TD; private: TD b (); };
7
by: Tony Johansson | last post by:
Hello Experts! I have the following Array template class see below. I execute these three statements statement 1: Array<int> x(5); statement 2: cin >>x; statement 3: Array<int>::element_type ...
2
by: PengYu.UT | last post by:
I have the following sample program, which can convert function object with 1 argument into function object with 2 arguments. It can also do + between function object of the same type. The last...
12
by: aaragon | last post by:
Hello all. I have a simple question that seems trivial but I can't make it to work. I have a class that takes as a template argument, another class. The idea is as follows: #include...
3
by: aaragon | last post by:
Hello everyone, I'm trying to run some simple code but for some reason it doesn't work and I've been staring at it for a long time without a single clue of what's going on. This is what happens,...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.