#include "string.h" int main(int argc, char **argv) { MyString mystr("alpha"); if (mystr.isSubstring("ph")) { std::cout << "true" << std::endl; } else std::cout << "false" << std::endl; /* uses copy ctor, compiler implicitly creates obj out of ", beta" and * then passess it to copy ctor */ MyString mystr1 = ", beta"; /* next to call ctor that takes in char arr */ MyString mystr2("charlie"); /* if it was () then it would be a fwd decl! */ MyString mystr3 = MyString(", delta"); mystr.concat(mystr1).concat(mystr2).concat(mystr3); std::cout << mystr << std::endl; MyString mystr4 = "hello"; mystr4.concat(", world!").concat(" goodbye"); std::cout << mystr4 << std::endl; /* test outward conversion */ const char *mystr_charptr = mystr4; std::cout << mystr_charptr << " | len: " << std::strlen(mystr_charptr) << std::endl; MyString mystr5 = "bro"; std::cout << mystr5 << ", char at 1 is: " << mystr5[1] << std::endl; /* getCount() is a static method hence it doesn't need to be called on * an object */ std::cout << "mystring instances count: " << MyString::getCount(); return 0; }