2016-07-14 15 views
0

は私がコンパイルしたいテンプレート・エラー・コードブロックは、C++、コードブロックは、エラー

||=== Build: Debug in gettype.t (compiler: GNU GCC Compiler) ===| 
gettype.t.c|6|error: expected '=', ',', ';', 'asm' or '__attribute__' before  '<' token| 
gettype.t.c|9|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token| 
gettype.t.c|10|error: expected '=', ',', ';', 'asm' or '__attribute__'  before '<' token| 
gettype.t.c|11|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token| 
gettype.t.c|12|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token| 
gettype.t.c|13|error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token| 
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| 

私はここで何が間違っていますか?:-(あなたの時間のために事前にthx :-) 歓声。

+4

(なぜあなたのヘッダーはとにかく.t拡張子を持っていますか?)の#includeに動作します含めます"gettype。*" '??? –

+2

FYI、質問タイトルはタグではなく、実際のタイトルです。 – HolyBlackCat

+0

#include "gettype。*"は間違いでした...拡張子.t – James

答えて

1

あなたが知られているタイプのためtemplate<typename T>なく、機能のテンプレートバージョンを「特化」する必要がある、あなただけのオーバーロードを必要としない:

std::string getType(int t) { return "int";} 
std::string getType(bool t) { return "bool";} 

のように。これらはテンプレートバージョンをオーバーロードします。

0

あなたは書いている:

#include "gettype.*" 

エラーメッセージがGCCがgettype.t.cと呼ばれるファイルを含むとCファイルとしてコンパイルしようとしていることを示しています。

私はあなたが何をしようとしては考えているが、あなたが解決した場合、あなたはそれだけでgettype.tないgettype.*を含み、それは `