簡単なプログラムを書いています。その中のクラスは1つだけです。プライベート メンバー 'char * number' と 2 つの関数があります (さらに多くの関数がありますが、最初にこれらが正しく動作するはずです:))。
最初のものは「ソース」を「数値」変数にコピーする必要があります(そして、ここのどこかに問題があると思います):
LongNumber::LongNumber(const char * source ){
int digits = strlen(source);
char* number = new char[digits+1];
strcpy( number, source );
// cout<<number<<endl; - if the line is uncommented,
// the output is correct and there isn't a problem
}
そして印刷機能:
void LongNumber::print(){
cout<<number<<endl;
// when I try to print with the same line of code here..it crashes
}
確かに、私は何かが欠けています...しかし、何ですか?
(これは私の最初の投稿です...タグは修正されていると思いますか..どのように投稿にタグを付けましたか?)
前もって感謝します :)