J
Jeff0803
Guest
That error occur from
#include <iostream>
using namespace std;
class String
{
private:
char* s;
int size;
public:
String(char*); // constructor
~String(); // destructor
};
String::String(char* c)
{
size = strlen(c);
s = new char[size + 1];
strcpy_s(s, size, c);
}
String::~String()
{
delete[]s;
}
int main()
{
char array[] = "Hello world";
String *s = new String(array);
delete[] array;
return 0;
}
Can anybody make it work?
Continue reading...
#include <iostream>
using namespace std;
class String
{
private:
char* s;
int size;
public:
String(char*); // constructor
~String(); // destructor
};
String::String(char* c)
{
size = strlen(c);
s = new char[size + 1];
strcpy_s(s, size, c);
}
String::~String()
{
delete[]s;
}
int main()
{
char array[] = "Hello world";
String *s = new String(array);
delete[] array;
return 0;
}
Can anybody make it work?
Continue reading...