summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index dd4810d..607b40c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -10,9 +10,13 @@ int main(int argc, char **argv)
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";
- MyString mystr2 = ", charlie";
- MyString mystr3 = ", delta";
+ /* 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;
@@ -21,9 +25,17 @@ int main(int argc, char **argv)
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;
}
-