I am working on trying to learn how to overload the << operator but my code keeps giving me errors. There are two errors whenever I compile in eclipse. One is invalid arguments for the line os << oper.factorial(num) . The other error is "num was not declared in this scope" on the same line. Any suggestions? (The top code is my header file, the bottom is my .cpp file)
Well your private member num is undefined, you never use it. So what is the factorial of ??? when you try to output? Anyways your setup is very questionable; you call the factorial function then output the factorial function so the first factorial call does pretty much nothing.
Why not simply do num = oper->factorial(num); or actually assign a value to num then