Hi,
I am making a String class that has many overloaded operators. I am positive there are some problems with the overloaded operators that I have already made. There are also some functions that I could not define and need help in defining. Can somebody please look at my code and tell me my errors and how to fix them as well as help me in defining the functions that are not yet defined.

Code:
//string.h

#ifndef _String_H
#define _String_H

#include <iostream>
#include "strdrv.h"
using namespace std;

class String
{
	friend String operator+(const String& lhs, const String& rhs);
	friend String operator+(const String& rhs, const char* str);
	friend String operator+(const char* str, const String& rhs);
	friend String operator+(const String& rhs, char str);
	friend String operator+(char str, const String& rhs);
	friend int operator==(const String& lhs, const String& rhs);
	friend int operator!=(const String& lhs, const String& rhs);
	friend int operator< (const String& lhs, const String& rhs);
	friend int operator<=(const String& lhs, const String& rhs);
	friend int operator> (const String& lhs, const String& rhs);
	friend int operator>=(const String& lhs, const String& rhs);
	friend char* operator+(const String&, int);
	friend char* operator+(int, const String&);
	friend ostream& operator<<(ostream&, const String&);

public:
	String();
	String(const char* str);
	String(char * nme);
	String(int string);
	String(const String& rhs);
	String(char, int);
	~String();
	void setName(const char* aname);
	String& operator= (const String& rhs);
	String& operator= (const char *st);
	const String& operator+=(const String & st);
	char& operator[](int i);
	char& operator[](int i) const;
	String& operator++();
	String& operator--();
	String operator++(int x);
	String operator--(int x);
	int getLength()const;
	String substr(int start, int length);
	void print();

private:
	int stringlength;
	int size;
	char * name;
	char *buf;



};

#endif 


// string.cpp
#define _CRT_SECURE_NO_DEPRECATE 1	
#include <iostream>
#include "string.h"
#include "strdrv.h"

using namespace std;

String::String()
{
	stringlength = 0;
	size = 1;
	buf = new char[size];
	buf[0] = '\0';
}

String::String(const char* str)
{ 
    if (str==NULL)
    {
        stringlength = 0; 
        buf = new char[1];  
        buf[0]='\0';
    }
    else
    {
        stringlength = strlen(str); 
        buf = new char[stringlength+1];
        for(int i=0; i <= stringlength; i++)
            buf[i] = str[i];
    }
}

String::String(char * nme)
{
	name = nme;
}

String::String(int string)
{
	if(string <= 0)
	{	
		stringlength = 0;
		buf = new char[1];
		buf[0] = '\0';
	}
	else
	{
		buf = NULL;
		stringlength = string;
		buf = new char[stringlength + 1];
	}
}



String::String(const String& rhs)
{
	stringlength = rhs.stringlength;
	buf = new char[stringlength + 1];
	for (int i=0; i <= stringlength; i++)
		buf[i] = rhs.buf[i];
}

String::~String()
{
	delete [] buf;
}

void String::setName(const char* aname)	
{
	name = new char[strlen(aname + 1)];		
	strcpy(name, aname);					
}

String& String::operator =(const String& rhs)
{
	if(this != &rhs)
	{
		delete []buf;
		stringlength = rhs.stringlength;
		buf = new char[stringlength + 1];
		for(int i = 1; i <= stringlength; i++)
			buf[i] = rhs.buf[i];
	}
	return *this;
}

String& String::operator =(const char *st)
{
	stringlength = strlen(st);
	if(size <= stringlength)
	{
		delete []buf;
		buf = new char[stringlength + 1];
	}
	strcpy(buf, st);
	return *this;
}
		

char& String::operator [](int i) const 
{
	if(i >= 0 && i<= stringlength)
		cout<< "Out of bounds" << endl;
	return buf[i];
}

char& String::operator [](int i)
{
	if(i >= 0 && i <= stringlength)
		cout<< "Out of bounds" << endl;
	return buf[i];
}

const String& String::operator +=(const String & str)
{
	String copystring(str);
	int anotherstringlength = getLength() + str.getLength();
	int previous = getLength();
	if(anotherstringlength >= size)
	{
		size = anotherstringlength + 1;
		char * secbuf = new char[size];
		strcpy(secbuf, buf);
		delete []buf;
		buf = secbuf;
	}
	strcpy(buf + previous, buf);
	stringlength = anotherstringlength;
	return *this;
}


String operator +(const String& lhs, const String& rhs)
{
	String result(lhs);
	result += rhs;
	return result;
}

String operator +(char str, const String& rhs)
{
	String result;
	result = str;
	result += rhs;
	return result;
}

String operator +(const String& rhs, char str)
{
	String result(rhs);
	result += str;
	return result;
}

String String::substr(int start, int length)
{
	if(start >= 0 && start < stringlength)
		cout<< "Start of substring not in string bounds" << endl;
	if(length >= 0)
		cout<< "Error: length of substring is negative" << endl;
	if((start + length) > stringlength)
		length = stringlength - start;
	char* stringArray = new char[length + 1];
	int i;
	for(i = start; i < (start + length) ; i++)
		stringArray[i-start] = (*this)[i];
	stringArray[i - start] = '\0';
	String temp(stringArray);
	delete []stringArray;
	return temp;
}



int operator==(const String& lhs, const String& rhs)
{
	return strcmp(lhs.buf, rhs.buf)==0;
}

int operator!= (const String& lhs, const String& rhs)
{
	return strcmp(lhs.buf, rhs.buf) !=0;
}

int operator< (const String& lhs, const String& rhs)
{
	return strcmp(lhs.buf, rhs.buf) <0;
}

int operator<= (const String& lhs, const String&rhs)
{
	return strcmp(lhs.buf, rhs.buf) <=0;
}

int operator> (const String& lhs, const String& rhs)
{
	return strcmp(lhs.buf, rhs.buf) >0;
}

int operator>= (const String& lhs, const String& rhs)
{
	return strcmp(lhs.buf, rhs.buf) >=0;
}

ostream& operator<< (ostream& output, const String& stringoutput)
{
	output<< stringoutput.buf;
	return output;
}


String& String::operator ++()
{
	buf[stringlength] = 'X';
	stringlength++;
	return *this;
}

String String::operator ++(int x)
{
	String Return("");
	Return = *this;
	buf[stringlength] = 'X';
	stringlength++;
	return Return;
}

String& String::operator --()
{
	stringlength--;
	return *this;
}

String String::operator --(int x)
{
	String Return("");
	Return = *this;
	stringlength--;
	return Return;
}

void String::print()
{
	int i;
	for(i= 0; i<stringlength; i++)
		printf("%c", buf[i]);
}

int String::getLength()const
{
	return stringlength;
}