|
-
March 14th, 2002, 01:17 PM
#1
pointer to a parametrized template
Hello, everybody!
I'm trying to do some programming in VC6, and ran into the following problem. I made a CMatrix<template T> class, that does some simple matrix calculations. Now I defined a (normal) class, in which I wanted to use a couple of these CMatrix'es in the following way:
CMatrix<double> *a;
(in the definition)
and to use a new operator with the parameterisation on these pointers later.
The compiler gives loads of errors :
missing ';' before '<'
'CMatrix' missing storage class or type specifiers
syntax error '<'
unexpected tokens preceding ';'
To me this makes no sense. Is this kind of thing impossible? Can anybody please help me?
Henk
-
March 14th, 2002, 01:39 PM
#2
Re: pointer to a parametrized template
Does your template header include the fully defined class? With templates, it is not enough to provide function prototypes - you have to provide their implementation too.
The best things come to those who rate
-
March 14th, 2002, 01:46 PM
#3
Re: pointer to a parametrized template
Yes, the template works in other instances...
Henk
-
March 14th, 2002, 01:49 PM
#4
Re: pointer to a parametrized template
did you include the header file in which it is declared - and use any namespace you needed to use ?
The best things come to those who rate
-
March 14th, 2002, 01:51 PM
#5
Re: pointer to a parametrized template
I included the matrix.h file, I'm not sure about the namespaces; the template works in all other things I tried...
Henk
-
March 14th, 2002, 04:04 PM
#6
Re: pointer to a parametrized template
The sure check to see if you are correct that matrix.h is included is to put the following line in matrix.h
#pragma message("Matrix.h is included")
This can go anywhere within the matrix.h file. When you compile your .CPP file, do you see the message "Matrix.h is included" in your compiler output window? If not, this means that you are not including the header, even though you think you are.
Regards,
Paul McKenzie
-
March 15th, 2002, 05:37 AM
#7
Re: pointer to a parametrized template
I've tried this, and indeed the header file is included after the definition of the class.... Have you any idea how to correct this?
Thank you very much! Henk
-
March 15th, 2002, 05:42 AM
#8
Re: pointer to a parametrized template
Well, everything works now.... It appears to be a problem of the order in which I include the header files, taking the matrix.h to the end of the list solved the errors. I didn't expect this! Oh well, for me there's always a bit of magic involved.
Thank you all for responding! Henk
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|