Having trouble overloading the << operator while working on a project. I made a pretty simple class to test it separately. It links fine however the program keeps crashing. On UNIX it defines it as a segmentation fault. I don't know what im doing wrong. Help would be much appreciated.
your operator keeps calling itself infinitely. So this will just keep calling itself and calling itself until you run out of stack space and the program explodes.
In this << operator, you have to tell it what to print. You can't tell it to print the Demo object like you are, because you are defining how the Demo object is supposed to be printed.
@OP
It looked to me like you were using the overload on line 22 to call the overload on line 13, which is why I asked where/if you defined it. But you can ignore that now, Disch was spot on.