I'm making an own class String in C++.
I have a problem with this:
class String {
char* arr;
int len;
friend ostream& operator << (ostream& s, const String& c) {
return s << c.arr;
}
Public:
String() {
arr = NULL;
len = 0;
}
String(const char* name) {
*arr = *name;
}
}
In main I have this:
String *s = new String("abcde");
cout << *s << endl;
The problem is that the compilator shows me this:
Bus error : 10
I'm working on a mac, using the terminal with g++.
How can I solve this problem?
Thanks in advance.