Hello, I have a program where I made an object called Poly to represent a polynomial. There is also a friend function which overloads the operator << so that cout will output a polynomial expression when fed a Poly object. The program is 500 lines long, so I am just showing the relevant parts. The problem lies in main() where what prints to the terminal is different before and after declaring some Poly objects. Why does the problem happen and how do I fix it?
using namespace std;
//some member variables here
//member function declarations
//some constructors and a destructor
//some member functions here
//some friend functions here
//overloaded << friend function:
cout << "works good"; //works fine
Poly p1, p2;
cout << "nothing now"; //nothing prints to the terminal
If that is your int main() then it doesn't call << for a Poly object, so it is irrelevant whether that output routine is correct or not (although @zapshe conjectures that it wouldn't be if it were used).
But as it stands you are calling a Poly constructor with no arguments.
And you haven't shown us what exactly is in your Poly class, or what a Poly constructor with no arguments would do.