C++: How would one implement their own String class? -


I am trying to re-learn C ++ and was thinking that someone can help me here I'm trying to apply my string class to see if I can remember things, but I'm stuck on the constructor.

I have my header file and make a constructor like this:

Header file (

  #ifndef STRING_ # Define STRING_ using the namespace std; # Include & lt; Iostream & gt; Square string {private: static constant unsigned int MAX = 32; // String Character Memory [Max] Capability; // String to catch characters in unsigned lanes; // Number of characters in string: public: // build string empty // string () {lane = 0; } // Reset string to empty // zero reset () {lane = 0; } // Return Status Information // Bull Blank () const {Return Lane == 0; Unsigned length () const {return lane; } // Return the element of the element i // char & amp; Operator [] (unsigned i) {return mem [i]; } // Return the constant reference of the element i // const char & amp; Operator [] (unsigned i) const {return mem [ii]; } // string creation by copying existing string // string (constant string & amp;;); // Create string by copying the array of characters / strings (const char []); // Copy string to existing string // string & amp; Operator = (Constant & amp;;); // string string current string // string & amp; Operator + = (constring & amp;;); }; // Compare two stars // BULL operator == (Const String & amp; Cont String & amp;;); Bull Operator! = (Const String & amp; Cont String & amp;;); // Put the string in an output stream / Ostream & amp; Operator & lt; & Lt; (Ostream and Constant String & amp;;); #endif   

The thing I'm stuck on is: string: string (string string and string) {// what's here ? }

Thanks!

OK, because this is a learning practice.

I think you want to copy the contents of other string here because it is a copy constructor. So you want to copy in all the member variables. In your case the copy creator is not required because you have got a steady array. If you have a dynamic memory (i.e. the new one used to allocate the pointer to the memer) then you will need it though, you are shown how this is done, you can go here.

  string :: string (constant string and string) {// what's going on here? Emphasis (str.Len & lt; MAX); Hope / Hope Memcpy (mem, str.Mem, str.Len); Lane = str.en; }    

Comments