それが私が考えることができる唯一のことです。物事は感性です。
私は次のような構造体を持っています:
struct NumPair
{
wchar_t *pFirst, *pSecond;
int count;
ctorを使用して、コピーの割り当てとコンストラクターを
NumPair( wchar_t *pfirst, wchar_t *psecond, int count = 0)
NumPair( const NumPair& np )
NumPair& operator=( const NumPair& np )
これは私の最後の問題の拡張であり、文字ポインタのリストを、などの特殊な(ドイツ語の)文字を含むものでソートする方法を求めていましたü, ä, ö
。
解決策はワイド文字タイプを使用しているようですが、コンパイラーは何らかの理由で100を超える変換エラーをスローしています。
サンプル入力:
// dict_ is a container of NumPairs.
dict_.push_back( NumPair ( "anfangen", "to begin, to start" ) );
const char *
コンパイラは、をに変換できないと文句を言っていますwchar_t
。結構です、push_backを次のように変更します
dict_.push_back( NumPair ( wchar_t("anfangen"), wchar_t("to begin, to start") ) );
コンパイラエラー:すべての引数を受け入れるNumPairコンストラクタが見つかりません。
何。。地獄。VSC ++ 10がおかしくなっていると思って、完全な再構築を試みました。いいえ、違います。
私は何が間違っているのですか?
コード
ctor、assignment、およびcopy構文はすべて、以下のようなwchar_tポインターのディープコピーです。
wchar.hが含まれています。
NumPair( wchar_t *pfirst, wchar_t *psecond, int count = 0)
: count(count)
{
size_t s1, s2;
s1 = wcslen(pfirst);
s2 = wcslen(psecond);
pFirst = new wchar_t[s1];
pSecond = new wchar_t[s2];
wcscpy(pFirst, pfirst);
wcscpy(pSecond, psecond);
}