class String
{
public:
String(const char*);
String();
friend int strcmpu(const String& lhs, const String& rhs);
private:
char* s;
int len;
};
// Implementation for it to compile("Big Three" issue exists)
#include
class String
{
public:
String(const char* in_s)
{
if (in_s)
{
s = new char[strlen(in_s) + 1];
strcpy(s, in_s);
} else {
String();
}
}
String()
{
s = 0;
len = 0;
}
friend int strcmpu(const String& lhs, const String& rhs);
private:
char* s;
int len;
};
int strcmpu(const String& lhs, const String& rhs)
{
return strcmp(lhs.s, rhs.s);
}
int main()
{
String s1="abc";
String s2="def";
return strcmpu(s1, s2);
}