Last active
December 5, 2018 09:50
-
-
Save metacollin/09b39068cf4b9bc1a60c82f8a24654a8 to your computer and use it in GitHub Desktop.
Revisions
-
metacollin revised this gist
Dec 5, 2018 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,13 +61,13 @@ int main() otherSub* test_class = new otherSub(); myGeneric* generic_test = new mySub(); // Output: getit(oSub); // myGeneric fuckit(oSub); // otherSub fuckit(teh_sub); // mySub fuckit(*generic_test); // mySub crushit(test_class); // otherSub crushit(&teh_sub); // mySub crushit(generic_test); // mySub return 0; -
metacollin created this gist
Dec 5, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ #include <iostream> class myGeneric { public: myGeneric() { }; virtual void id() { std::cout << "myGeneric" << std::endl; }; }; class mySub : public myGeneric { public: void id() override { std::cout << "mySub" << std::endl; }; }; class otherSub : public myGeneric { public: void id() override { std::cout << "otherSub" << std::endl; }; }; void getit(myGeneric generic) { generic.id(); } void fuckit(myGeneric &generic) { generic.id(); } void crushit(myGeneric* generic) { generic->id(); } int main() { mySub teh_sub; otherSub oSub; otherSub* test_class = new otherSub(); myGeneric* generic_test = new mySub(); // Output: getit(oSub); // myGeneric fuckit(oSub); // otherSub fuckit(teh_sub); // mySub fuckit(*generic_test); // mySub crushit(test_class); // otherSub crushit(&teh_sub); // mySub crushit(generic_test); // mySub return 0; }