Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Template argument as template argument

Reply
Thread Tools

Template argument as template argument

 
 
nw
Guest
Posts: n/a
 
      04-14-2008
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;

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
r H2 deduce deduce template argument of a template class inheritingfrom a non template base? nguillot C++ 5 03-08-2009 05:56 PM
template template argument from specialized instance gao_bolin@voila.fr C++ 0 03-29-2005 05:36 PM
May a template argument be a friends of the template class? BigMan C++ 4 03-29-2005 02:28 AM
Template function as argument to another template function Jim West C++ 3 10-07-2004 07:21 PM
Passing template struct as an argument to a template function nifsmith C++ 5 09-27-2004 02:35 PM



Advertisments