<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Visual C++ Tips &#187; //</title>
	<atom:link href="http://weseetips.com/tag/1072/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Can C++ Style comments replace C-Style comments?</title>
		<link>http://weseetips.com/2008/04/05/can-c-sytle-comments-replace-c-style-comments/</link>
		<comments>http://weseetips.com/2008/04/05/can-c-sytle-comments-replace-c-style-comments/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 17:56:03 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[/*]]></category>
		<category><![CDATA[//]]></category>
		<category><![CDATA[C Style Comments]]></category>
		<category><![CDATA[CPP style comments]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[Visual C++]]></category>

		<guid isPermaLink="false">http://weseetips.wordpress.com/?p=62</guid>
		<description><![CDATA[While entering to C++ world, the first thing we used to learn is &#8211; Avoid C-Style comments, always use C++ style comments and a number of drawbacks of C-Style comments. But don&#8217;t think that C++ comments are omni. Still there are places where C++ style comments cannot be used. Usually inside macros, we don&#8217;t write [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-11" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg" alt="" width="166" height="32" /><br />
While entering to C++ world, the first thing we used to learn is &#8211; Avoid C-Style comments, always use C++ style comments and a number of drawbacks of C-Style comments. But don&#8217;t think that C++ comments are omni. Still there are places where C++ style comments cannot be used.</p>
<p><img class="alignnone size-full wp-image-15" src="http://weseetips.files.wordpress.com/2008/03/icon_underthehood.jpg" alt="" width="208" height="32" /><br />
Usually inside macros, we don&#8217;t write comments. But if the macro is too complex, adding comments will be better for future. But can we use C++ style comments? See the following code block.</p>
<pre>#define CHECK_AND_DELETE_PTR( ptr ) \
    // Check whether the pointer is valid \
    if( ptr ) \
    { \
        // Delete the pointer \
        delete ptr; \
}</pre>
<p>The code block won&#8217;t compile. Because C++ style comments always look for end-of-line as termination and the backslash delimiter that we add will concatenate the next line and that too will become the part of comment. Since macro body should be in a single line, we cannot omit the backslash delimiter.</p>
<p>See the same macro with C-Style comments which is perfect.</p>
<pre>#define CHECK_AND_DELETE_PTR( ptr ) \
    /* Check whether the pointer is valid */ \
    if( ptr ) \
    { \
        /* Delete the pointer */ \
        delete ptr; \
    }</pre>
<p>Immortal C. Isn&#8217;t it? <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img class="alignnone size-full wp-image-53" src="http://weseetips.files.wordpress.com/2008/03/intermediateseries.jpg" alt="" width="248" height="32" /><br />
Targeted Audience &#8211; Intermediate.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2008/04/05/can-c-sytle-comments-replace-c-style-comments/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

