I am in a College c++ course working on data structures and I have gotten to the List class we need to use it to implement a Fibonacci number calculator. I have gotten the program to work perfectly on Microsoft Visual Studio however when i upload it to the school Linux Lab using a G++ compiler it fails to compile I cant seem to find the problem between the two compilers. The list.h was the list class i wrote and i know that works fine.
this is the error I'm getting... its being displayed by every fiboNumbers.push_front
g++ -c fibonacci.cpp
fibonacci.cpp: In function ‘void fibonacci()’:
fibonacci.cpp:65:45: error: no matching function for call to ‘WholeNumber::WholeNumber(WholeNumber)’
fiboNumbersOne.push_front(WholeNumber(zero));
^
fibonacci.cpp:65:45: note: candidates are:
In file included from fibonacci.cpp:13:0:
fibonacci.h:20:2: note: WholeNumber::WholeNumber(WholeNumber&)
WholeNumber(WholeNumber & rhs);
^
fibonacci.h:20:2: note: no known conversion for argument 1 from ‘WholeNumber’ to ‘WholeNumber&’
fibonacci.h:19:2: note: WholeNumber::WholeNumber(int)
WholeNumber(int input);
^
fibonacci.h:19:2: note: no known conversion for argument 1 from ‘WholeNumber’ to ‘int’
fibonacci.h:18:2: note: WholeNumber::WholeNumber()
WholeNumber();
^
fibonacci.h:18:2: note: candidate expects 0 arguments, 1 provided
In file included from fibonacci.h:13:0,
from fibonacci.cpp:13:
list.h:255:6: error: initializing argument 1 of ‘void List<T>::push_front(T) [with T = WholeNumber]’
void List<T>::push_front(T item)
You will have to define a move constructor or/and define a constructor which takes WholeNumber by value.
If you just made your code const-correct it would be fine as is. VC++ has a compiler extension enabled by default that allows a regular reference to bind to a non-const object, which is not allowed by the standard.