#include "String.h" #include #include String::String(const char* str) : str( strdup(str) ) , len( strlen(str) ) { } String::String(const String &other) : str( strdup(other.str) ) , len( other.len ) { } const String& String::operator =(const String &other) { // Evita fugas de memoria si se asgina el objeto a si mismo if ( this != &other ) { free(str); str = strdup(other.str); len = other.len; } return *this; } String::~String() { free(str); } std::ostream& operator<<(std::ostream& output, const String& str) { return output << str.str; }