#include <iostream>
using std::cout;
using std::endl;
struct String {
String(char *_p);
~String();
void print();
private:
char *p;
};
String::String(char *_p) {
p = new char[strlen(_p) + 1];
if (!p) {
cout << "new error" << endl;
exit(1);
}
strcpy(p, _p);
}
String::~String() {
delete p;
}
void String::print() {
cout << p << endl;
}
int main()
{
String o("c++");
o.print();
return 0;
}
/*
run:
c++
*/