<?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>Reflections of my thoughts... &#187; C++</title>
	<atom:link href="http://codereflect.com/category/c-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://codereflect.com</link>
	<description>on programming tips and trending topics...</description>
	<lastBuildDate>Wed, 08 Feb 2012 08:58:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>const to data and pointer</title>
		<link>http://codereflect.com/2011/02/23/const-to-data-and-pointer/</link>
		<comments>http://codereflect.com/2011/02/23/const-to-data-and-pointer/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 08:57:52 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1424</guid>
		<description><![CDATA[This is a fundamental thing that every C++ programmers must know. const to data This is the simplest form of pointer definition that we always do. const int* data3 = arr2; // Const to data data3[0] = 55;  // ERROR: Data can't be changed data3 = arr1;    // Success:  Can't change the pointer to somewhere [...]]]></description>
			<content:encoded><![CDATA[<p>This is a fundamental thing that every C++ programmers must know.</p>
<h2>const to data</h2>
<p>This is the simplest form of pointer definition that we always do.</p>
<pre>
const int* data3 = arr2; // Const to data
data3[0] = 55;  // ERROR: Data can't be changed
data3 = arr1;    // Success:  Can't change the pointer to somewhere else
</pre>
<p>Here the data is can’t changed using data3 pointer. but the pointer itself can be modified and can point to some other location.</p>
<p>Usually  we don’t care even if pass the pointer to some function and that  pointer changes to some other location, as the function parameters  points to same location but the pointer is a copy of actual parameter.  But things may go different if we wrongly pass reference to function  parameters even it’s const. So we’ve to take care this while designing  the interfaces.</p>
<pre>
void Foo(  LPCTSTR&amp; lpszValue )
{
	lpszValue = _T( &quot;codereflect.com&quot; );
}

int _tmain(int argc, _TCHAR* argv[])
{
	LPCTSTR sz = NULL;
	Foo(sz);
	_tprintf( sz );
	return 0;
}
</pre>
<h2>const to pointer</h2>
<p>In this form of usage, the pointer can’t be changed to some location but the data can be changed.</p>
<pre>
int* const data2 = arr2; // const to pointer
data2 = arr1;    // Can't change the pointer to somewhere else
data2[0] = 55;  // SUCCESS: Data can be changed
</pre>
<h2>const to both data and pointer</h2>
<p>This is the goodness of both <img src='http://codereflect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The most secure pointer.</p>
<pre>
const int* const data1 = arr1; // Const to both pointer and data
data1 = arr2;    // ERROR: can't change the pointer
data1[0] = 100; // ERROR: can't change the data
</pre>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2011/02/23/const-to-data-and-pointer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2005 or above and Processor based optimization</title>
		<link>http://codereflect.com/2010/01/29/visual-studio-2005-or-above-and-processor-based-optimization/</link>
		<comments>http://codereflect.com/2010/01/29/visual-studio-2005-or-above-and-processor-based-optimization/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 15:53:35 +0000</pubDate>
		<dc:creator>@sarat</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://codereflect.com/?p=1085</guid>
		<description><![CDATA[The /G switch ( /G3, /G4, /G5, /G6, /G7, and /GB ) was used optimize the code for the specific processor architecture like Pentium, Pentium II, Pentium III and IV etc. This was possible with Visual C++ prior to VC++ 8.0 (Visual Studio 2005). But this compiler option is no more supported. The compiler now [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/h66s5s0e(VS.71).aspx" target="_blank">The /G switch ( /G3, /G4, /G5, /G6, /G7, and /GB )</a> was used optimize the code for the specific processor architecture like Pentium, Pentium II, Pentium III and IV etc. This was possible with Visual C++ prior to VC++ 8.0 (Visual Studio 2005). But this compiler option is no more supported. The compiler now generates code in a blended mode which works well with all architectures. This is especially need to be taken care while works with makesfiles on switching over from previous version of  Visual C++ versions.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms177253(VS.80).aspx" target="_blank">See more information on breaking changes with Visual C++ 2005 Compiler</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codereflect.com/2010/01/29/visual-studio-2005-or-above-and-processor-based-optimization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

