<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: 4.2 &#8212; Global variables</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/42-global-variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/</link>
	<description></description>
	<pubDate>Wed, 20 Aug 2008 09:11:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Learn C++ - &#187; 4.1 &#8212; Blocks (compound statements) and local variables</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-13457</link>
		<dc:creator>Learn C++ - &#187; 4.1 &#8212; Blocks (compound statements) and local variables</dc:creator>
		<pubDate>Tue, 29 Apr 2008 04:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-13457</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; 3.8 &#8212; Bitwise operators &#124; Home &#124; 4.2 &#8212; Global variables &#187;     Monday, June 18th, 2007 at 10:06 [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; 3.8 &#8212; Bitwise operators | Home | 4.2 &#8212; Global variables &raquo;     Monday, June 18th, 2007 at 10:06 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-13295</link>
		<dc:creator>Stuart</dc:creator>
		<pubDate>Mon, 28 Apr 2008 00:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-13295</guid>
		<description>"Launching nuclear missiles", LOL. Evil globals; don't trust 'em.

Anyway, I just wanted to say that these tutorials are really good. Thanks. ;D</description>
		<content:encoded><![CDATA[<p>&#8220;Launching nuclear missiles&#8221;, LOL. Evil globals; don&#8217;t trust &#8216;em.</p>
<p>Anyway, I just wanted to say that these tutorials are really good. Thanks. ;D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-10500</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 28 Mar 2008 16:23:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-10500</guid>
		<description>I honestly can't think of the last time I used a global variable.

Typically, people use global variables for one of three reasons:
1) Because they don't understand C++ variable passing mechanics, or they're being lazy.
2) To hold data that needs to be used by the entire program (eg. configuration settings).
3) To pass data between code that doesn't have a caller/callee relationship (eg. multi-threaded programs)

Obviously #1 isn't a good reason at all.  Once you get into C++ classes, there are better ways to do #2 (eg. static classes).  That pretty much leaves #3, and maybe a few other cases I'm not aware of.

Basically, the only time you should use a global variable is if there is no practical way to do what you want using local variables and variable passing mechanics.  In my opinion, use of globals should always be a last resort -- so in a way, it's a "you'll know it when you run into it" situation, as there simply won't be any other reasonable way to proceed.</description>
		<content:encoded><![CDATA[<p>I honestly can&#8217;t think of the last time I used a global variable.</p>
<p>Typically, people use global variables for one of three reasons:<br />
1) Because they don&#8217;t understand C++ variable passing mechanics, or they&#8217;re being lazy.<br />
2) To hold data that needs to be used by the entire program (eg. configuration settings).<br />
3) To pass data between code that doesn&#8217;t have a caller/callee relationship (eg. multi-threaded programs)</p>
<p>Obviously #1 isn&#8217;t a good reason at all.  Once you get into C++ classes, there are better ways to do #2 (eg. static classes).  That pretty much leaves #3, and maybe a few other cases I&#8217;m not aware of.</p>
<p>Basically, the only time you should use a global variable is if there is no practical way to do what you want using local variables and variable passing mechanics.  In my opinion, use of globals should always be a last resort &#8212; so in a way, it&#8217;s a &#8220;you&#8217;ll know it when you run into it&#8221; situation, as there simply won&#8217;t be any other reasonable way to proceed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sorin</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-10485</link>
		<dc:creator>Sorin</dc:creator>
		<pubDate>Fri, 28 Mar 2008 07:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-10485</guid>
		<description>How do I know if I have a really good reason? Can you give us an example from your experience where you decided you should use a global variable, please?</description>
		<content:encoded><![CDATA[<p>How do I know if I have a really good reason? Can you give us an example from your experience where you decided you should use a global variable, please?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vivek Singh</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-3506</link>
		<dc:creator>Vivek Singh</dc:creator>
		<pubDate>Tue, 27 Nov 2007 12:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-3506</guid>
		<description>Thanks that was great!

I was facing problem with global variable declaration and using it into mutiple files.

The problem is fixed.</description>
		<content:encoded><![CDATA[<p>Thanks that was great!</p>
<p>I was facing problem with global variable declaration and using it into mutiple files.</p>
<p>The problem is fixed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
