473,394 Members | 1,817 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,394 software developers and data experts.

Template as an argument to a class

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
2 1991
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Elven | last post by:
Hi! I was trying to find the solution to this problem, but I don't think I could quite come up with the correct keywords to find it, since I'm pretty sure it's been asked before. In short,...
8
by: vpadial | last post by:
Hello, I want to build a library to help exporting c++ functions to a scripting languagge. The scripting language provides a function to register functions like: ANY f0() ANY f1(ANY) ANY...
3
by: case2005 | last post by:
Can anyone help with the following, I don't know if it's possible, but I'm certain there must be a standard way of dealing with this. I have the following: template<typename FooBar, typename...
6
by: PengYu.UT | last post by:
Hi, I have the following program which use a template as a template parameter. But it seems that it doesn't work. Do you know how to make it work? Although I can change the lines with...
3
by: Chris | last post by:
I am having a very strange problem involving virtual functions in template classes. First of all, here is an extremely simplified structure of the two classes I am having problems with. ...
6
by: rincewind | last post by:
Hi, can anybody summarise all options for partial template specialization, for all kind of parameters (type, nontype, template)? I *think* I understand options for partial specialization on...
2
by: Greg Buchholz | last post by:
/* I've been experimenting with some generic/polytypic programs, and I've stumbled on to a problem that I can't quite figure out. In the program below, I'm trying to define a generic version of...
5
by: Wayne Shu | last post by:
Hi, guys I am reading Vandevoorde and Josuttis 's "C++ Template The Complete Guide" these days. When I read the chapter 15: Traits and Policy classes. I copy the code in 15.2.2 that use to...
8
by: William Xu | last post by:
Compiling: template <class T = int> T foo(const T& t) {} int main(int argc, char *argv) {} gcc complains:
2
by: Clyde | last post by:
Hi, what i'm trying to do is: /////////////// Code Start template <class TType, int* p = 0> class Template { public:
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.