{"id":34,"date":"2008-01-23T19:07:56","date_gmt":"2008-01-23T23:07:56","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=34"},"modified":"2008-01-27T14:01:30","modified_gmt":"2008-01-27T18:01:30","slug":"refresh-c","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=34","title":{"rendered":"Refresh C++"},"content":{"rendered":"<p>General<\/p>\n<ul>\n<li>Include\n<ul>\n<li>#include &lt;iostream&gt; \/\/ Notice no semicolon<\/li>\n<\/ul>\n<\/li>\n<li>Namespace\n<ul>\n<li>using namespace std;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Modifiers<\/p>\n<ul>\n<li>static\n<ul>\n<li>Exist throughout application life time<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>sizeof<\/p>\n<ul>\n<li>Return number of bytes occupied by the object<\/li>\n<li>sizeof number;<\/li>\n<li>sizeof(long);<\/li>\n<\/ul>\n<p>new<\/p>\n<ul>\n<li>Dynamically allocates heap memory<\/li>\n<li>Returns address of the space allocated (a pointer)<\/li>\n<li>Can only be de-allocated by delete<\/li>\n<li>Example<br \/>\n<code lang=\"cpp\"><br \/>\n\/\/ Declare a pointer<br \/>\ndouble* pval = NULL;<br \/>\n\/\/ Test for out of memory<br \/>\nif (!(pval = new double)){<br \/>\ncout &lt;&lt; \"Out of memory...\";<br \/>\nexit(1);<br \/>\n}<br \/>\n\/\/ Allocate a double and initialize it<br \/>\npval = new double(999.0);<br \/>\n\/\/ Release memory pointed by pval<br \/>\ndelete pval;<br \/>\n\/\/ Declar a char pointer<br \/>\nchar* pstr = NULL;<br \/>\n\/\/ Allocate a string of 20 characters<br \/>\npstr = new char[20];<br \/>\n\/\/ Delete array pointed to by pstr<br \/>\ndelete [] pstr;<\/code><\/li>\n<\/ul>\n<p>Debugging<\/p>\n<ul>\n<li>Go\n<ul>\n<li>Stop at the first break point<\/li>\n<\/ul>\n<\/li>\n<li>Step into\n<ul>\n<li>Run one statement at a time<\/li>\n<\/ul>\n<\/li>\n<li>Step over\n<ul>\n<li>Run one statement in the main() function at a time\u00a0<\/li>\n<\/ul>\n<\/li>\n<li>Run to cursor\n<ul>\n<li>Run to where you position the text cursor<\/li>\n<\/ul>\n<\/li>\n<li>Attach\n<ul>\n<li>Debug a program that&#8217;s already running<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>General Include #include &lt;iostream&gt; \/\/ Notice no semicolon Namespace using namespace std; Modifiers static Exist throughout application life time sizeof Return number of bytes occupied by the object sizeof number; sizeof(long); new Dynamically allocates heap memory Returns address of the &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=34\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-cpp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-y","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":0,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}