Friday, July 31, 2009

C++ programming. My problems are with a String class.?

Good afternoon! :-)





How should I write it correctly?


1st function: void print(std::ostream%26amp; os);


2nd function: static void copy(String%26amp; string1, String string2); (it (I mean the second) copies the matter of string2 to string1)


The private members of the class are: unsigned int elementsNum; and char*pData; .


These were my "small" problems. My "big" problem is that I have to alter my program to be able to treat with UNICODE characters.





So, these (3) are my questions. Only one answer would help me a lot, so if you can answer just one of my questions, it would be lovely.





Thank you!!!





Domonkos

C++ programming. My problems are with a String class.?
(1) will end up being something like:





void String::print(std::ostream%26amp; os)


{


os %26lt;%26lt; pData;


}





3) has an obvious solution but non-trivial implementation - use templates, exactly like the STL has chosen to do. Write and get the class working for chars and then generalize it via templates to wchars and possibly alternate allocators.





2) This is harder to help you with without more info. What are your constructors, copy constructor, overloaded operators, append methods, etc., that you anticipate having in the class?
Reply:Hi,





This link may help you - http://www.jorendorff.com/articles/unico...





Also the book Win32 system programming has excellent explanation and examples on using unicode


http://www.amazon.com/gp/reader/02016346...


No comments:

Post a Comment