2016-04-15 14 views
-2

このコードでは、実際にうまく見える2つのテンプレートベースの関数を示しています。どちらも構文は同じですが、どちらか一方のみ有効です。私はさまざまな種類の実装を試してきましたが、どれも最初のものとは連携していませんでした。あなたが尋ねる前に:私は...私を助けてくれ何の解決策を見つけていないC++コンパイルエラーC4430

しかし、ここでのコードを見て:

#pragma once 

#include <exception> 
#include <iostream> 
#ifdef WIN32 
#include <Windows.h> 
#endif //WIN32 
#include <string> 

namespace util { 

    /* ############### */ 
    /* #    # */ 
    /* # For strings # */ 
    /* #    # */ 
    /* ############### */ 



    template<class T = std::string> 
    bool hasPrefix(const T& string, const, T& prefix); 

    template<class T = std::string> 
    bool hasPostfix(const T& string, const T& postfix); 

} 

template<class T> 
bool util::hasPrefix(const T& string, const T& prefix) { 
    //CODE 
} 

template<class T> 
bool util::hasPostfix(const T& string, const T& prefix) { 
    //CODE 
} 

私がコンパイルしようとすると、今、Visual Studioは、私にこのエラーを与える:

エラーC4430:欠落している型指定子が想定されています!

hasPrefix(...)のみで、hasPostfix(...)では使用できません! 私はstatic_assert(...)またはfor(...) - ループなしで実装しようとしました。 ヘッダやその他のものを変更しても助けにならなかったので、2番目のテンプレート関数がうまく機能するので、このエラーはわかりません。私は誰かが

答えて

2
template<class T = std::string> 
bool hasPrefix(const T& string, const, T& prefix); 
//         ^

私を助けることができると思います

は、あなたがやっていることにもっと注意を払います。

typoは、動作する宣言とそうでない宣言を見るだけで明らかです。

+0

どうもありがとうございました。 :/ – tistCoder

関連する問題