170. Write down String class copy constructor ?
Microsoft Interview Questions and Answers
(Continued from previous question...)
170. Write down String class copy constructor ?
Question:
Write down String class copy constructor ?
maybe an answer1:
class string
{
private:
char *str;
size_t length;
public:
string(const string& other)
{
length = strlen(other.str);
str = new char[length + 1];
strcpy(str, other.str);
}
};
(Continued on next question...)
Other Interview Questions
|