Monday, 15 June 2015

c++ - operator/ overloading -


For the purpose of learning, I am creating a bigger integer class in C ++: 2 files are:

< / P>

big_int.h

  #ifndef BIG_INT_H #define BIG_INT_H #include square big_int {public: big_ant (zero); Big_int (four *); Big_int (QString); ~ Big_int (); Big_int operator + (big_int); Big-operator- (big_nint); Big_int operator * (big_int); Big_int operator / (big_int); }; #endif // BIG_INT_H  


big_int.cpp

  #include "big_int .h "big_int :: big_int () {} big_int :: big_int (qstring str) {} big_int :: ~ big_int () {} big_int operator + (big_int b) {return big_int (); } Big_int operator- (big_int b) {return big_int (); } Big_int operator * (big_int b) {return big_int (); } Big_int operator / (big_int) {return big_int (); }  

Qt creator returns: C: / documents and settings / admin / admin / my document / calculator_1_0 / big_INPCPP: 31: error: big operator / (big_net) should take exactly two arguments. But operator / takes only 1 parameter what is wrong?

This is a typo, you have forgotten the name of the class:

 < Code> big_nint big_nint :: operator + (big_it b) {return big_int (); } Big_int big_int :: operator- (big_int b) {return big_int (); } Big_int big_int :: operator * (big_int b) {return big_int (); } Big_int big_int :: operator / (big_int) {return big_int (); }  

By the way, you should take contant context instead of values:

  big_int big_int :: operator / (const big_int and v) {// .}  

1 comment: