added some comments for class Char, and added some TODO's
This commit is contained in:
		
							
								
								
									
										6
									
								
								Char.cpp
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								Char.cpp
									
									
									
									
									
								
							@@ -10,11 +10,11 @@ Char& Char::operator=(char other)
 | 
			
		||||
{
 | 
			
		||||
    auto data = new char[_string.size() + 2];   // space for new char & null-terminator
 | 
			
		||||
    std::strcpy(data, _string.c_str());
 | 
			
		||||
    data[_index] = other;
 | 
			
		||||
    data[_index] = other;                       // set the desired char
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    _string._str->operator--();
 | 
			
		||||
    _string._str = new StringValue(data);
 | 
			
		||||
    _string._str->operator--();                 // release old StringValue
 | 
			
		||||
    _string._str = new StringValue(data);       // make a new one
 | 
			
		||||
 | 
			
		||||
    return *this;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								Char.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Char.h
									
									
									
									
									
								
							@@ -5,6 +5,9 @@ class StringValue;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// TODO: think about making ctors explict
 | 
			
		||||
/* This class provides a simple wrapper for a char primitive, and implements
 | 
			
		||||
 * copy-on-write semantics for the non-const String::operator[] via some magic */
 | 
			
		||||
class Char
 | 
			
		||||
{
 | 
			
		||||
private:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user