Untitled
unknown
c_cpp
a year ago
551 B
7
Indexable
#include "String.hpp" #include <cstring> String::String( const char* str ) { if( str ) { // Jeżeli podamy ciąg inny niż pusty ("") m_length = strlen( str ); m_value = new char[ m_length + 1 ]; strcpy( m_value, str ); m_value[ m_length ] = '\0'; // Czy potrzebne? Przemeśleć } else { // Podajemy ciąg pusty ("") m_length = 0; m_value = new char[ 1 ]; m_value[ 0 ] = '\0'; } } String::~String() { delete[] m_value; }
Editor is loading...
Leave a Comment