I almost got my user defined string class to work but not quite. When I execute the program, I get a memory error. Code is as follows.
#include
using namespace std;
class String {
char *str; //pointer to character block
public:
String();
String (char *s);
void setString (char *s);
int stringLength();
char getString();
};
String::String() {}
String::String(char *s)
{
int length=strlen(s); //length of string
str=new char[length+1]; //increments length of string
strcpy(str,s); //copies s to str
cout<