|
-
May 31st, 2009, 08:22 AM
#8
Re: basic string scope in std namespace
char* argv[] is simply an array of C-style strings corresponding to command-line arguments. You'll sometimes see the parameter declared as char ** argv, which is equivalent.
At the lowest level---where C lives---any string is just an array of characters. Hence the type is char*. However, classes such as std::string were creating specifically so that you wouldn't have to worry about such details. Consider the progression:
Array of char arrays: char**
Array of std::strings: std::string*
std::vector of std::strings: std::vector<std::string>
At each step we wrap a C++ class around a pointer, allowing us not to worry about the specifics of dealing with pointers. That's not to say that the three types are 100% compatible in all cases, but they're essentially similar.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|