quote:
Original post by EbonySeraph
IMHO, I think that you should use a standard character array(string) for your needs. Unless there are some clear advantages to using std::string that you didn''t mention. You could also be missing a library like string.h(though you should have it using strlen() ).
benefits of using std::basic_string:
- automatically grows to whatever size needed
- automatically frees memory when destroyed
- length stored internally so strlen takes constant, not linear time
- can hold nulls
- all the std::string operations you can do on it which are handy member functions, instead of searching through string.h for the right function
- the member functions are all inlined
- I think, but I''m not sure, that it does reference counting too.
liabilities of std::basic_string:
- 16-byte structure instead of a 4-byte pointer.
- mandatory construction costs (which can be the same as for a char * when done correctly)
quote:
If anyone else replies to this topic, what exactly does the :: operator do other than to define member functions of a class?
It doesn''t define anything. It''s the scope resolution operator, which works on any name that has sub-names (namespaces, classes, structs, unions). A::B tells the compiler to find B as a subname of A. ::B tells the compiler to find B at global scope (i.e. all WIN32 names).