Template argument as template argument

N

nw

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;

}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top