ここで本当に簡単な質問です。仮想関数を使用してテキストファイルから読み込みています。ある面では値を正規化する必要があり、別の面では値を正規化したくないので、これは仮想です。私はこれをやろうとしました:
bool readwav(string theFile, 'native');
したがって、理論的には、「native」を使用する場合はこのメソッドを呼び出す必要がありますが、「double」を呼び出す場合は、別のバージョンのメソッドが呼び出されます。値が空の場合も同様で、ネイティブオプションを実行するだけです。
最初の質問、なぜ上記の宣言が機能しないのですか?また、これは降りるのに最適なルートですか?または、オプションを切り替えるクラスメソッドを1つだけ持つ方がよいでしょうか。
ありがとう :)
アップデート:
どこが間違っているのですか?
bool Wav::readwav(string theFile, ReadType type = NATIVE)
{
// Attempt to open the .wav file
ifstream file (theFile.c_str());
if(!this->readHeader(file))
{
cerr << "Cannot read header file";
return 0;
}
for(unsigned i=0; (i < this->dataSize); i++)
{
float c = (unsigned)(unsigned char)data[i];
this->rawData.push_back(c);
}
return true;
}
bool Wav::readwav(string theFile, ReadType type = DOUBLE)
{
// Attempt to open the .wav file
ifstream file (theFile.c_str());
cout << "This is the double information";
return true;
}