私はこのようなクラスを持っています:
class largeInt{
vector<int> myVector;
largeInt operator* (const largeInt &arg);
}
私のメインでは、ポインタを操作している間、コピーを避けることはできません:
void main(){
//this works but there are multiple copies: I return a copy of the calculated
//largeInt from the multiplication and then i create a new largeInt from that copy.
largeInt testNum = 10;
largeInt *pNum = new HugeInt( testNum*10);
//i think this code avoid one copy but at the end hI points to a largeInt that has
// myVector = 0 (seems to be a new instance = 0 ). With simple ints this works great.
largeInt i = 10;
largeInt *hI;
hI = &(i*10);
}
ベクターデザインで何かが欠けている/管理されていないと思います。新しいlargeIntをインスタンス化せずに、ポインターのコピーレス割り当てを実現できますか?専門家に感謝します!