Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようなすべてのフォームで機能する単一のテンプレート仕様を作成したいと思います。
char*, const char*, char* const
等...
C ++構文でこれを行うにはどうすればよいですか?
ありがとうございました。
3つのバージョンすべてで機能し、同じように機能する関数を作成する場合は、テンプレートは実際には必要ありません。これを示すサンプルプログラムは次のとおりです。
void f(const char* const c) { } int main() { char ch='h'; char*c=&ch; const char*cc="hi"; char* const cc1=&ch; f(c); f(cc); f(cc1); }
g++4.7で正常にコンパイルされます。