Programming Exercises

1:Consider the following class declaration:
class Cow {
    char name[20];
    char * hobby;
    double weight;
public:
    Cow();
    Cow(const char * nm, const char * ho, double wt);
    Cow(const Cow c&);
    ~Cow();
    Cow & operator=(const Cow & c);
    void ShowCow();  // display name, hobby, and weight of a cow
};

Provide the implementation for this class and write a short program that uses all the member functions.

2:Enhance the String class declaration (that is, upgrade strng2.h to string3.h) by doing the following:
  1. Overload the + operator to allow you to join two strings into one.

  2. Provide a stringlow() member function that converts all alphabetic characters in a string to lowercase. (Don't forget the cctype family of character functions.)

  3. Provide ...

Get The Waite Group's C++ Primer Plus, Third 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.