SVN / public / code / vorlesung-06 / StringMain.cpp

Revision 11340
Date
Committerhb1003
Download
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Hannah Bast <bast@cs.uni-freiburg.de>.

#include <stdio.h>
#include "./String.h"

// Doof function for demonstrating effects when passing or returning objects.
String& doofFunction() {
  printf("Enter doofFunction\n");
  String result;
  result.set("Doof");
  printf("Leave doofFunction\n");
  return result;
}

// Main function (for demonstration purposes only, not needed für Ü6).
int main(int argc, char** argv) {
  printf("Enter main function\n");
  String x = doofFunction();  // Exactly the same as String x(doofFunction());
  printf("Leave main function\n");
}

// String x; x = doofFunction();  // This would call operator=(...).

// String result1;
// result1.set("Doof");
// String result2;
// result2.set("Bloed");
// printf("Leave doofFunction\n");
// return result1.length() < result2.length() ? result1 : result2;