Template argument as template argument

Discussion in 'C++' started by nw, Apr 14, 2008.

  1. nw

    nw Guest

    Hi All,

    Could someone point me in the right direction with this code? If I
    change "myclass<_prec>::atype t = 0;" to " myclass<double>::atype t
    = 0;" it compiles. Am I not allowed to use a template argument as a
    template argument for another class? gcc gives the error:

    templateargasarg.cpp:17: error: expected `;' before 't'
    templateargasarg.cpp:18: error: 't' was not declared in this scope

    Any help appreciated.

    #include <iostream>

    using namespace std;

    template<class _prec=double>
    class myclass {
    public:

    typedef int atype;
    };

    template<class _prec=double>
    class myclass2 {
    public:

    _prec method() {
    myclass<_prec>::atype t = 0;
    return t;
    }
    };

    int main() {

    myclass2<> m;

    }
     
    nw, Apr 14, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nifsmith
    Replies:
    5
    Views:
    8,268
    Maitre Bart
    Sep 27, 2004
  2. Jim West
    Replies:
    3
    Views:
    784
    Jim West
    Oct 7, 2004
  3. BigMan
    Replies:
    4
    Views:
    3,681
    Malte Starostik
    Mar 29, 2005
  4. Replies:
    0
    Views:
    395
  5. nguillot
    Replies:
    5
    Views:
    559
Loading...

Share This Page