I recently started to study classes and operator overloading in C++, and wrote following Bignum class in order to pratice. Link: http://pastebin.com/cQNwRChx. It's not a final version, for example there is no exception handling and maybe it's not so effective, so I want to clarify some questions:
- This code is successfully compiled in MSVS 2010, but GNU C++ 4.4.1 says, that 'fft' was not declared in this scope in line 465.
- I use Fast Fourier transform to multiply numbers when the result is huge. Because of very slow standard complex numbers, I wrote my own implementation. In my opinion, these complex numbers should be hidden, because it's like a part of Lint implementation. So I declare it as a private nested class of Lint, and declare fft as a friend of Lint. Why it doesn't work in GNU?
- The debugger of MSVS shows, that constant ONE isn't a static constant. It's defined below, after Lint's definition.
- I would like to use class with int, unsigned int and etc. in expressions, and current version works fine, but also I want to have an opportunity to write something like this:
if (a) ...
, where a is Lint. But if I define implicit conversion to bool and writea+b
, where a is int and b is Lint, there is an ambiguity. How can I solve this problem?
UPD. There is a simple pseudo-code without excess functions and definitions: http://pastebin.com/rauKQjtH.