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

Template as an argument to a class

P: n/a
Greetings,

I am trying to create a template class called Matrix that operates on a
template class called complex.

Now of course complex is a template class and I want it to be the argument
for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS with CC
ver 6.2.

Any help will be appreciated.

Thanks.
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Richard Cromer wrote:
Greetings,

I am trying to create a template class called Matrix that operates on
a template class called complex.

Now of course complex is a template class and I want it to be the
argument for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS
with CC ver 6.2.


I think you will need template template parameters. I am not sure if Forte
6.2 supports it.

--
Attila aka WW
Jul 19 '05 #2

P: n/a
On Thu, 21 Aug 2003 07:51:56 -0400, "Richard Cromer"
<ri************@kodak.com> wrote:
Greetings,

I am trying to create a template class called Matrix that operates on a
template class called complex.

Now of course complex is a template class and I want it to be the argument
for Matrix.

So I have something like:
template <class T> class complex {/*..*/}

then I want to use complex in Matrix like this:
template <class T2> class Matrix {/*..*/} where T2 is of type
complex<double>.

Has anyone ever done anything like that? I am using Solaris 2.6 OS with CC
ver 6.2.


Matrix<complex<double>/*note a space is required*/> m;
e.g.
Matrix<complex<double> > m;
Matrix<complex<double>> m;
is a syntax error, since the last >> is a right shift operator, where
you need two > tokens instead. This is considered a major problem with
the C++ "max munch" parsing (which grabs the biggest token available),
but there is an intention to fix it for the next version of the C++
standard.

Tom
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.