Q1: What do you mean by "turn in only p9.C" on the broadcast announcement?
Q2: My cout operator ( << ) keeps causing a "Segmentation Fault". On my
computer the error message was "Stack overflow".
The code I have for the overloaded operator is simply:
ostream& operator<< (ostream& os, const Strg& s)
{ os << s; return os; }
--------------------------------------------------------------------------------
Q1: What do you mean by "turn in only p9.C" on the broadcast announcement?
A1: You are typing in 3 files, p9main.C p9.h and p9.C
Use the command: turnin -c cs10u p9.C
This will submit ONLY the file that the autograder wants.
--------------------------------------------------------------------------------
Q2: My cout operator ( << ) keeps causing a "Segmentation Fault". On my
computer the error message was "Stack overflow".
The code I have for the overloaded operator is simply:
ostream& operator<< (ostream& os, const Strg& s)
{ os << s; return os; }
A2: Change to: os << s.str; // Print character string
from: os << s; // Recursive call
The " << " operator is written already (overloaded) to handle
"char s[]" therefore will print out a character string.
The " << " operator does NOT know how to handle a "Strg" object.
Therefore you are calling this same function (recursion - Thursday's
lecture) passing a Strg object AGAIN.
--------------------------------------------------------------------------------