Constructing a string from a C String

Now that we've disposed of the default constructor, let's take a look at the line in our string interface definition (Figure 7.1 on page 405): string(char* p);.[7] This is the declaration for another constructor; unlike the default constructor we've already examined, this one has an argument, namely, char* p.[8]

[7] I know we've skipped the copy constructor, the assignment operator, and the destructor. Don't worry, we'll get to them later.

[8] There's nothing magical about the name p for a pointer. You could call it George if you wanted to, but it would just confuse people. The letter p is often used for pointers, especially by programmers who can't type, which unfortunately is fairly common.

As we saw in ...

Get C++: A Dialog Programming with the C++ Standard Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.