{"id":976,"date":"2019-06-19T18:14:04","date_gmt":"2019-06-19T23:14:04","guid":{"rendered":"http:\/\/dragonlordwarlock.com\/blog\/?p=976"},"modified":"2019-06-19T18:14:08","modified_gmt":"2019-06-19T23:14:08","slug":"linkable-object-c-hello-world","status":"publish","type":"post","link":"https:\/\/dragonlordwarlock.com\/blog\/?p=976","title":{"rendered":"Linkable Object C++ Hello World"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ thello.hpp\n#include &lt;iostream>\n#include &lt;string>\n#include &lt;iomanip>\n\nusing namespace std;\n\nclass THello\n{\n\tstring TGreeting;\n\tunsigned long TRepeatCount;\npublic:\n\tTHello();\n\tTHello(string UserGreeting);\n\tTHello(unsigned long Count);\n\tTHello(string UserGreeting, unsigned long Count);\n\tvoid AssignGreeting(string UserGreeting);\n\tvoid AssignRepeat(unsigned long Count);\n\tvoid operator&lt;&lt;(string UserGreeting);\n\tvoid run();\n};\n\n\/\/thello.cpp\n#include \"thello.hpp\"\n\nvoid THello::AssignGreeting(string UserGreeting)\n{\n\tTGreeting = UserGreeting;\n}\n\nvoid THello::AssignRepeat(unsigned long Count)\n{\n\tif(Count>0) TRepeatCount = Count;\n}\n\nTHello::THello()\n{\n\tAssignGreeting(\"Hello World.\");\n\tAssignRepeat(10);\n}\n\nTHello::THello(string UserGreeting)\n{\n\tAssignGreeting(UserGreeting);\n\tAssignRepeat(10);\n}\n\nTHello::THello(unsigned long Count)\n{\n\tAssignGreeting(\"Hello World.\");\n\tAssignRepeat(Count);\n}\n\nTHello::THello(string UserGreeting, unsigned long Count)\n{\n\tAssignGreeting(UserGreeting);\n\tAssignRepeat(Count);\n}\n\nvoid THello::operator&lt;&lt;(string UserGreeting)\n{\n\tAssignGreeting(UserGreeting);\n}\n\nvoid THello::run()\n{\n\tunsigned int i = 1;\n\twhile(i&lt;=TRepeatCount)\n\t{\n\t\tcout &lt;&lt; \"[\" &lt;&lt; setfill('0') &lt;&lt; setw(5) &lt;&lt; i &lt;&lt; \"] \";\n\t\tcout &lt;&lt; TGreeting &lt;&lt; endl;\n\t\ti++;\n\t}\n}\n<\/pre>\n\n\n\n<p>This creates an object that can be linked to a main program containing all hello world services to a parent program.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include \"hellolib\\thello.hpp\"\n#include &lt;cstdlib>\n#include &lt;string>\n\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n\tswitch(argc)\n\t{\n\t\tcase 1:\n\t\t{\tTHello World;\n\t\t\tWorld.run();\n\t\t\tbreak;\n\t\t}\n\t\tcase 2:\n\t\t{\n\t\t\tlong i = atol(argv[1]);\n\t\t\tTHello World( i );\n\t\t\tWorld.run();\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t{\n\t\t\tlong i = atol(argv[1]);\n\t\t\tstring s = argv[2];\n\t\t\tTHello World( s , i );\n\t\t\tWorld.run();\n\t\t}\n\t}\n\treturn 0;\n}\n<\/pre>\n\n\n\n<p>A sample program using that object.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This creates an object that can be linked to a main program containing all hello world services to a parent program. A sample program using that object.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29,30,33,32],"tags":[],"class_list":["post-976","post","type-post","status-publish","format-standard","hentry","category-c","category-hello-world","category-object-oriented-programming","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=976"}],"version-history":[{"count":1,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/976\/revisions"}],"predecessor-version":[{"id":977,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/976\/revisions\/977"}],"wp:attachment":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}