CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2002
    Posts
    8

    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


  2. #2
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    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

  3. #3
    Join Date
    Mar 2002
    Posts
    8

    Re: pointer to a parametrized template

    Yes, the template works in other instances...

    Henk


  4. #4
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    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

  5. #5
    Join Date
    Mar 2002
    Posts
    8

    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


  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    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


  7. #7
    Join Date
    Mar 2002
    Posts
    8

    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


  8. #8
    Join Date
    Mar 2002
    Posts
    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
  •  





Click Here to Expand Forum to Full Width

Featured