I have some code which does not work and I was just wondering why and also how to fix it.
The error I get is:Code:else if( choice == 1 ) { long unsigned int num; cout << "\nEnter number: "; cin >> num; if ( prime( num ) == 1 ) cout << "The number is prime."; else cout << "The number is NOT prime."; } int prime( int &number ) { ... }
It works if the variable 'num' is just a plain int.test.cpp:40: error: could not convert `num' to `int&'
test.cpp:5: error: in passing argument 1 of `int prime(int&)'
Would it help speed up the program by using references llike I have? Another block of code in the program sends plenty long unsigned ints to a function for processing and I just thought that using references might reduce overhead and speed up things. If not I will happily just pass by value.