[問題] operator <<的問題
我的CLASS
BigInt.h
#include <malloc.h>
#include <iostream>
#include <string.h>
using namespace std;
#ifndef BIGINT_H
#define BIGINT_H
class BigInt {
friend ostream& operator<<(ostream &output , BigInt &x);
private:
char * _digits; // Array: 儲存字元
int _capacity; // Array 大小
int _numDigits; // 整數位數
int _sign; // 正負號 正1 負-1
}
#endif
BigInt.cpp
#include "bigint.h"
ostream& operator<<(ostream& output,BigInt& x){
for( int i=x._capacity-1; i>=0; i-- )
if(x._digits[i]!=0)
break;
if(x._sign==-1&&i!=-1)
output<<"-";
if( x._numDigits == 0 ||i==-1)
output << '0';
else
for(; i>=0; i-- ){
if((int)x._digits[i]<10 &&i != x._capacity-2)
output<<0;
output << (int)x._digits[i];}
output << endl;
return output;
}
雖然身為朋友 可是BigInt卻不肯把private的變數借出來
這樣算什麼朋友(我是VC6)
error C2248: '_capacity' : cannot access private member declared in class
'BigInt'
該怎麼修改呢ˊˋ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.136.174.4
推
05/06 17:27, , 1F
05/06 17:27, 1F
→
05/06 17:27, , 2F
05/06 17:27, 2F
→
05/06 17:42, , 3F
05/06 17:42, 3F
→
05/06 18:02, , 4F
05/06 18:02, 4F
→
05/06 18:02, , 5F
05/06 18:02, 5F
→
05/06 18:03, , 6F
05/06 18:03, 6F
→
05/06 19:30, , 7F
05/06 19:30, 7F