EXERCISES

All the exercises are with reference to class STRING.

  1. Write a program to sort an array of strings in ascending order of string length.
  2. Write a program to remove duplicates from an unsorted array of strings.
  3. Overload Unary operator ‘++’ such that all characters are changed to its uppercase equivalents.
  4. Overload Unary operator ‘--’ such that all the characters are changed to its lowercase equivalents.
  5. Develop method charAt (int n). It should return the nth character from the string.
  6. Write a method to check whether any white space character is present in the string.
  7. Write a function test to check if newline (‘\n’) character is part of a string.
  8. Write a method toString() to convert string object to ordinary string (C-string).

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.