<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 4.3 &#8212; File scope and the static keyword</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 12:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: lynx1241</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-95655</link>
		<dc:creator>lynx1241</dc:creator>
		<pubDate>Sun, 03 Jul 2011 16:02:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-95655</guid>
		<description>In english it&#039;s called square root. C++ doesn&#039;t have a square root operator, like all other programming languages I know. But it does have a sqrt function in the &quot;cmatch&quot; library.</description>
		<content:encoded><![CDATA[<p>In english it&#8217;s called square root. C++ doesn&#8217;t have a square root operator, like all other programming languages I know. But it does have a sqrt function in the &#8220;cmatch&#8221; library.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jon</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-91488</link>
		<dc:creator>jon</dc:creator>
		<pubDate>Mon, 06 Sep 2010 03:00:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-91488</guid>
		<description>Also, since it is only declared once and not every time the function is called, it conserves memory. Right?</description>
		<content:encoded><![CDATA[<p>Also, since it is only declared once and not every time the function is called, it conserves memory. Right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrAlshahawy</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-91373</link>
		<dc:creator>MrAlshahawy</dc:creator>
		<pubDate>Sat, 04 Sep 2010 07:13:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-91373</guid>
		<description>Consider Static variable as a combination between Global and Local Variables benefits:

Static takes the benefit of keeping its value after you go out of the scope just like Global, At the same time you avoid the downside of Global variable which is that any other functions may change its value causing unpredictable values.</description>
		<content:encoded><![CDATA[<p>Consider Static variable as a combination between Global and Local Variables benefits:</p>
<p>Static takes the benefit of keeping its value after you go out of the scope just like Global, At the same time you avoid the downside of Global variable which is that any other functions may change its value causing unpredictable values.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unknown</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-90489</link>
		<dc:creator>unknown</dc:creator>
		<pubDate>Wed, 18 Aug 2010 11:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-90489</guid>
		<description>I have read everything so far, but to me they&#039;ve missed some mathematical signs like the opposite of x^2, like ? (x)  I don&#039;t know how it&#039;s called in english but in dutch it&#039;s called: worteltrekken :P
But, thx anyway Alex ;)</description>
		<content:encoded><![CDATA[<p>I have read everything so far, but to me they&#8217;ve missed some mathematical signs like the opposite of x^2, like ? (x)  I don&#8217;t know how it&#8217;s called in english but in dutch it&#8217;s called: worteltrekken :P<br />
But, thx anyway Alex ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CodeChaos</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-86249</link>
		<dc:creator>CodeChaos</dc:creator>
		<pubDate>Thu, 10 Jun 2010 03:17:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-86249</guid>
		<description>The name &quot;file scope&quot; is technically incorrect. It can even be misleading. For example, consider you have two files, eg.h and eg.cpp:

&lt;i&gt;eg.h&lt;/i&gt;
&lt;pre&gt;static int myvar; //file scope!?&lt;/pre&gt;

&lt;i&gt;eg.cpp&lt;/i&gt;
&lt;pre&gt;#include &quot;eg.h&quot;

int main()
{
   myvar = 2; //this is OK. what!?
   return 0;
}&lt;!--formatted--&gt;&lt;/pre&gt;

Since eg.h is &lt;b&gt;&lt;i&gt;included&lt;/i&gt;&lt;/b&gt; in eg.cpp, anything declared in eg.h as &quot;file scope&quot; will still be accessible in eg.cpp, even though it was in a different source file. This is because both source code files are compiled into the same object (*.o) file.

&quot;File scope&quot; should really be &quot;object scope&quot;.</description>
		<content:encoded><![CDATA[<p>The name &#8220;file scope&#8221; is technically incorrect. It can even be misleading. For example, consider you have two files, eg.h and eg.cpp:</p>
<p><i>eg.h</i></p>
<pre>static int myvar; //file scope!?</pre>
<p><i>eg.cpp</i></p>
<pre>#include &quot;eg.h&quot;

int main()
{
   myvar = 2; //this is OK. what!?
   return 0;
}<!--formatted--></pre>
<p>Since eg.h is <b><i>included</i></b> in eg.cpp, anything declared in eg.h as &#8220;file scope&#8221; will still be accessible in eg.cpp, even though it was in a different source file. This is because both source code files are compiled into the same object (*.o) file.</p>
<p>&#8220;File scope&#8221; should really be &#8220;object scope&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-78375</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Mon, 15 Feb 2010 17:18:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-78375</guid>
		<description>Brad -

The easiest way would be to write the variable to a file at the end of the program, then read it back in again when the program is next run.</description>
		<content:encoded><![CDATA[<p>Brad -</p>
<p>The easiest way would be to write the variable to a file at the end of the program, then read it back in again when the program is next run.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Oertel</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-78005</link>
		<dc:creator>Phil Oertel</dc:creator>
		<pubDate>Sun, 07 Feb 2010 03:50:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-78005</guid>
		<description>Alex, thank you for this excellent tutorial! Great explanation of what is otherwise quite a tricky set of concepts.</description>
		<content:encoded><![CDATA[<p>Alex, thank you for this excellent tutorial! Great explanation of what is otherwise quite a tricky set of concepts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-76998</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Sat, 23 Jan 2010 03:21:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-76998</guid>
		<description>I assume static variables reset every time the program is exited? Is there a way to keep a variables value even after the program ends? Say for instance you wanted to create a counter that keeps up with how many time a program was run or a particular function was called?</description>
		<content:encoded><![CDATA[<p>I assume static variables reset every time the program is exited? Is there a way to keep a variables value even after the program ends? Say for instance you wanted to create a counter that keeps up with how many time a program was run or a particular function was called?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: earlmw</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-75238</link>
		<dc:creator>earlmw</dc:creator>
		<pubDate>Fri, 01 Jan 2010 01:35:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-75238</guid>
		<description>It really has since the original K&amp;R C programming</description>
		<content:encoded><![CDATA[<p>It really has since the original K&amp;R C programming</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Falcon</title>
		<link>http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/comment-page-1/#comment-75044</link>
		<dc:creator>Falcon</dc:creator>
		<pubDate>Tue, 29 Dec 2009 14:29:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/43-file-scope-and-the-static-keyword/#comment-75044</guid>
		<description>Yes these variables will be having global scope. If you are declaring variables in source1.h they should be preceded with &quot;extern&quot; keyword.</description>
		<content:encoded><![CDATA[<p>Yes these variables will be having global scope. If you are declaring variables in source1.h they should be preceded with &#8220;extern&#8221; keyword.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

