By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,408 Members | 945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,408 IT Pros & Developers. It's quick & easy.

Define template parameter or just declare?

P: n/a
Hi,

I want to do something like this:

foo.h:
class FooData;
typedef MyTemplate<FooData> MyFoo;

class Foo2: public MyFoo {
// ...
};

foo.cpp:
class FooData {
// ...
};

Assume that MyTemplate only uses pointers to its template parameter and
never calls any methods on it (just passes pointers to it to other
routines/classes). I seem to remember reading that this won't work,
because you always have to define (not just declare) a class before you
use it as a template parameter. Is this right?

Cheers,
Jim

Jun 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
qu*************@yahoo.co.uk wrote:
Hi,

I want to do something like this:

foo.h:
class FooData;
typedef MyTemplate<FooData> MyFoo;

class Foo2: public MyFoo {
// ...
};

foo.cpp:
class FooData {
// ...
};

Assume that MyTemplate only uses pointers to its template parameter and
never calls any methods on it (just passes pointers to it to other
routines/classes). I seem to remember reading that this won't work,
because you always have to define (not just declare) a class before you
use it as a template parameter. Is this right?

I don't think so, the class has to be in scope when the template is
instantiated.
--
Ian Collins.
Jun 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.