Re: About class constructores with templates
On 2007-11-16 19:31:17 -0500, peter koch <peter.koch.larsen@gmail.com> said:
On 17 Nov., 00:05, "parag_p...@hotmail.com" <parag_p...@hotmail.com>
wrote:
hi All ,
I am giving the pseudo code about the problem I am talking about .
I have a class hiearchy which looks like this.
class A;
template <class X1, class X2> class B : public A{}
template <class X3> class C: public B<Xreal1, Xreal2>;
The syntax of what you attempt above is
template <class X3,class Xreal1,class Xreal2> class C: public
B<Xreal1, Xreal2>;
Maybe. But if Xreal1 and Xreal2 are the names of types, then B<Xreal1,
Xreal2> is fine as originally written. Which is why this "pseudo-code"
is pointless.
Now is it necessary to put the following statement before the line
above like the following
template <Xreal1, Xreal2> class B;
Yes it is - you have to declare B before you can use it!
No, the template B has already been defined. Aside from the fact that
its definition isn't valid, because it says that A is a base class, but
A hasn't been defined.
And, of course, the message header says something about contructors,
although the "pseudo-code" doesn't show any constructors.
It's rarely worthwhile trying to figure out what sketches like this are
supposed to show. Which is why the FAQ says to post complete, minimal
examples. That way, people can compile the code for themselves and see
what's really going on.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)