TestString::TestString(int num)
This is a conversion constructor that should convert an integer to a string.
For example, if 123 is passed in, the TestString object should store the string data that would be represented by the c-string "123".
class TestString //header file
{
public:
TestString (int num);
//etc.
private:
int size;
char* str;
};
TestString::TestString (int num) //.cpp file
{
char c = static_cast<char>(num);
str = new char[size]; //missing size variable
int i = 0;
for (i; cstr[i] != '\0'; i++) //missing cstr array
str[i] = cstr[i];
str[i] = cstr[i]; //to tack on null character
}
As you can tell I am missing both the size variable and cstr string in the definition. I don't know if I'm going about this all wrong or just having trouble understanding what sort of setup I'm being asked for...
Any pointers or suggestions greatly appreciated.
Only libraries permitted:
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cctype>