   syntax error 'return'   - c++
  The compiler's having new year fun with me right?std::string Order::getPaymentsSaveString(void){std::string outString;std::ostringstream oss;outString = "";ListOfPayments::iterator paymentIter = paymentList.begin();while (paymentIter != paymentList.end()){outString.append((*paymentIter)->getSaveString());}paymentIter++;if (paymentIter == paymentList.end()){outString.append("\n");}else {outString.append(" ");}}return outString;}gives error C2059: syntax error : 'return'   on the return at the bottom of the function.Have the machines finally turned against me, or is it my mind?   
  You have too many closing braces, the return is actually outside of the method's body!..std::string Order::getPaymentsSaveString(void){std::string outString;std::ostringstream oss;outString = "";ListOfPayments::iterator paymentIter = paymentList.begin();while (paymentIter != paymentList.end()){outString.append((*paymentIter)->getSaveString());}  // <<<<<<<<<<<<<<< Delete this brace <<<<<<<<<<<<<<<paymentIter++;if (paymentIter == paymentList.end()){outString.append("\n");}else {outString.append(" ");}}return outString;};// In C++ we typically leave out the 'void' when the argument list// is empty - just write getPaymentsSaveString()std::string Order::getPaymentsSaveString(void){std::string outString;std::ostringstream oss;   // This line is unnecessary (the string constructor leaves the string   // 'empty' by default)outString = "";ListOfPayments::iterator paymentIter = paymentList.begin();while (paymentIter != paymentList.end()){outString.append((*paymentIter)->getSaveString()); // Errant bracket here (most likely the cause of the error)}paymentIter++;if (paymentIter == paymentList.end()){outString.append("\n");}else {outString.append(" ");}}return outString;};  Thanks both.It never ceases to amaze me how easy it is to spot errors like that in the code of others, yet the huge amount of time it takes to find these things in one's own code...   ;  Consistent formatting ftw. No, seriously. You have a mix of K&R and Block style indentation and bracing. That's a recipe for trouble. Stay consistent.   ;  A simple change to your algorithm enables a much cleaner expression of it:std::string Order::getPaymentsSaveString() {std::string outString;// Instead of checking for the last item, we'll just handle all items,// and then *replace* the last space with a return.for (ListOfPayments::iterator paymentIter = paymentList.begin();paymentIter != paymentList.end();++paymentIter) {// operator overloading FTWoutString += (*paymentIter)->getSaveString() + " ";}outString[outString.length() - 1] = '\n';return outString;}