problems with string classes

i have both the testing program and the header file for a class. i need to write the class functions.
here is the testing program
[#include<iostream>
#include "String1030.h"

using std::cout;
using std::cin;

int main()
{
// check the constructors
String1030 s("My string");
String1030 t(s);
String1030 x;

char in_buf[256];


cout << "S size(): " << s.getSize() << endl;
cout << "T size(): " << t.getSize() << endl;
cout << "X size(): " << x.getSize() << endl;

for(int i=0;i<t.getSize();i++)
cout << t[i];
cout << endl;

s[2]='5';

for(int i=0;i<s.getSize();i++)
cout << s[i];
cout << endl;

// check the assignment operator
x=s;
cout << "X: " << x.getString() << endl;

// check the size reset.
x.setSize(30);

cin >> in_buf;
x.setString(in_buf);
cout << "\nx: " << x.getString() << endl;


//more checks on resize

//set to a negative value, nothing should change
s.setSize(-8);
cout << "S size(): " << s.getSize() << endl;

//set to 0, should be 0
s.setSize(0);
cout << "S size(): " << s.getSize() << endl;

//read into the 0 length array should NOT have an error
//and should NOT transfer any characters. Output should not
//have any errors either.
cin >> in_buf;
s.setString(in_buf);
cout << "S after cin>>: " << s.getString() << endl;

//reset to something larger than 0
s.setSize(10);
cout << "S size(): " << s.getSize() << endl;

//read should work now
cin >> in_buf;
s.setString(in_buf);
cout << "S after cin>>: " << s.getString() << endl;

//now the assignment return value

x=t=s;

cout << "T: " << t.getString() << endl;
cout << "X: " << x.getString() << endl;

system("pause");


return 0;
}

here is the header
class String1030
{

public:

String1030(const char *buf=0);
String1030(const String1030& oldstring);
~String1030();

String1030& operator=(const String1030& right);


char& operator[](int index);

int getSize(void);
void setSize(int newsize);
const char *getString();

void setString(const char *carray);


private:
char *buffer;
int mysize;

};


#endif

and here is what i tried for my functions (does not work)
#include<iostream>
using namespace std;

#include "String1030.h"

String1030::String1030(const char *buf): mysize(0), buffer(0)
{
setSize(mysize);

}

String1030::String1030(const String1030& oldstring)
{
setSize(oldstring.mysize);

for(int i = 0; i<mysize; i++)
{
buffer[i]=oldstring.buffer[i];
}
}

String1030::~String1030()
{
delete [] buffer;
}

int String1030::getSize()
{

}

void String1030::setSize(int newsize)
{
newsize=mysize;

}

const char* String1030::getString()
{
return buffer;
}

void String1030::setString(const char *carray)
{
*buffer = *carray;
}

String1030& String1030::operator=(const String1030& right)
{
setSize(right.mysize);
for(int i = 0; i < mysize; i++)
{
buffer[i]=right.buffer[i];
}
return *this;
}

char& String1030::operator[](int index)
{
return buffer[index];
}

the printout should look like this
S size(): 9
T size(): 9
X size(): 0
My string
My5string
X: My5string
StringOne
x: StringOne
S size(): 9
S size(): 0
StringTwo
S after cin>>: StringTwo
S size(): 10
StringThree
S after cin>>: StringThree
T: StringThree
X: StringThree

any help would be appreciated
thanks
Topic archived. No new replies allowed.