h*b
1 楼
以下选哪一个
class String {
char *s;
int length;
public:
String(const char *);
String();
/* add code here */
};
int main()
{
String s1 = "abc";
String s2 = "def";
strcmp(s1, s2);
getchar();
return(1);
}
Referring to the sample code above, which one of the following member
functions do you add at the comment in order to allow the strcmp(s1, s2)
statement to compile?
operator const char*() const { return s; }
char* const operator() const { return s; }
operator char*
class String {
char *s;
int length;
public:
String(const char *);
String();
/* add code here */
};
int main()
{
String s1 = "abc";
String s2 = "def";
strcmp(s1, s2);
getchar();
return(1);
}
Referring to the sample code above, which one of the following member
functions do you add at the comment in order to allow the strcmp(s1, s2)
statement to compile?
operator const char*() const { return s; }
char* const operator() const { return s; }
operator char*