'GNU MP best alternative for functions that should "return" something
So, let's say you want to write a C++ program and implement a function which returns the incremented value of a variable by 1; you'd probably do something like this:
int next(int n) {
return n+1;
}
When trying to do the same thing with mpz_t's, you'll have noticed that the compiler complains about the fact that mpz_t represents an array. Therefore, an alternative is needed.
What I'd do spontaneously is to declare all required variables in the global scope and make the return type of my functions "void", so that the functions only modify globally defined variables.
Is this good? Are there better alternatives?
EDIT: I've just found that GMP variables are passed by reference. Problem solved.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
