<?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.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>
	<lastBuildDate>Thu, 02 Feb 2012 21:20:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: anoushe</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-96477</link>
		<dc:creator>anoushe</dc:creator>
		<pubDate>Sun, 27 Nov 2011 01:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-96477</guid>
		<description>Hi,

I&#039;m trying to solve a matrix equation outside of my main function i.e. I form the matrices A and b in my main function then pass them onto a solver.cpp file which then solves them and gets me the x. I now want to use that x (which is an array defined as double *x=new double [m] ) in my main function. Can someone please help with this? I&#039;ve tried several ways but keep getting errors. 
Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;m trying to solve a matrix equation outside of my main function i.e. I form the matrices A and b in my main function then pass them onto a solver.cpp file which then solves them and gets me the x. I now want to use that x (which is an array defined as double *x=new double [m] ) in my main function. Can someone please help with this? I&#8217;ve tried several ways but keep getting errors.<br />
Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-96150</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 15 Oct 2011 14:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-96150</guid>
		<description>Uhh, if I understand you correctly, you just need to have x as a global variable and then you can access it from inside the block, and use it again in a different one.</description>
		<content:encoded><![CDATA[<p>Uhh, if I understand you correctly, you just need to have x as a global variable and then you can access it from inside the block, and use it again in a different one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ranjbar</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-96147</link>
		<dc:creator>ranjbar</dc:creator>
		<pubDate>Fri, 14 Oct 2011 14:27:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-96147</guid>
		<description>hi

#include 
int main()
{
    using namespace std;
    cout &lt;&gt; nValue;

    if (nValue &gt; 3)

        {
            cout &lt;&lt; &quot;A&quot;&lt;&lt;endl;


                    cout &lt;&lt; &quot;enter a number&quot;&lt;&gt; x;
        }

}

suppose  out of the block of if i need  value of x. what can i do for getting value of x out of the block?</description>
		<content:encoded><![CDATA[<p>hi</p>
<p>#include<br />
int main()<br />
{<br />
    using namespace std;<br />
    cout &lt;&gt; nValue;</p>
<p>    if (nValue &gt; 3)</p>
<p>        {<br />
            cout &lt;&lt; &quot;A&quot;&lt;&lt;endl;</p>
<p>                    cout &lt;&lt; &quot;enter a number&quot;&lt;&gt; x;<br />
        }</p>
<p>}</p>
<p>suppose  out of the block of if i need  value of x. what can i do for getting value of x out of the block?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-96114</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 08 Oct 2011 12:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-96114</guid>
		<description>organization. 
headers are usually used for forward declarations and whatnot, while cpp files are used to hold the code.</description>
		<content:encoded><![CDATA[<p>organization.<br />
headers are usually used for forward declarations and whatnot, while cpp files are used to hold the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hpoonis</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-95912</link>
		<dc:creator>hpoonis</dc:creator>
		<pubDate>Mon, 22 Aug 2011 10:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-95912</guid>
		<description>I have to ask...

Why would you need to create a file (say) globals.cpp AND ALSO globals.h to call the .cpp?  Why not just call the file globals.h instead and use that?

It just seems pointless having two files do the same thing as one.</description>
		<content:encoded><![CDATA[<p>I have to ask&#8230;</p>
<p>Why would you need to create a file (say) globals.cpp AND ALSO globals.h to call the .cpp?  Why not just call the file globals.h instead and use that?</p>
<p>It just seems pointless having two files do the same thing as one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: astronaut13</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-95685</link>
		<dc:creator>astronaut13</dc:creator>
		<pubDate>Fri, 08 Jul 2011 13:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-95685</guid>
		<description>Okay. So, a very good reason for a global variable might be in a game - a player&#039;s name and inventory status, etc. Right?</description>
		<content:encoded><![CDATA[<p>Okay. So, a very good reason for a global variable might be in a game &#8211; a player&#8217;s name and inventory status, etc. Right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: defining a variable in a header file?</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-95490</link>
		<dc:creator>defining a variable in a header file?</dc:creator>
		<pubDate>Wed, 25 May 2011 11:38:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-95490</guid>
		<description>[...] to functions than making them global. You can read some reason why global variables are evil here (scroll down a [...]</description>
		<content:encoded><![CDATA[<p>[...] to functions than making them global. You can read some reason why global variables are evil here (scroll down a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-95482</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 21 May 2011 20:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-95482</guid>
		<description>http://store.steampowered.com/app/1520/
Someone already did it.</description>
		<content:encoded><![CDATA[<p><a href="http://store.steampowered.com/app/1520/" rel="nofollow">http://store.steampowered.com/app/1520/</a><br />
Someone already did it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: recusive mutex problem</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-95052</link>
		<dc:creator>recusive mutex problem</dc:creator>
		<pubDate>Fri, 17 Dec 2010 17:43:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-95052</guid>
		<description>[...] You&#039;re probably using C or C++... ... and you probably need to declare &quot;PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP&quot; as a global, &quot;extern&quot; variable in a .h header file. For example:  http://www.learncpp.com/cpp-tutorial...bal-variables/ [...]</description>
		<content:encoded><![CDATA[<p>[...] You&#039;re probably using C or C++&#8230; &#8230; and you probably need to declare &quot;PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP&quot; as a global, &quot;extern&quot; variable in a .h header file. For example:  <a href="http://www.learncpp.com/cpp-tutorial...bal-variables/" rel="nofollow">http://www.learncpp.com/cpp-tutorial&#8230;bal-variables/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony</title>
		<link>http://www.learncpp.com/cpp-tutorial/42-global-variables/comment-page-1/#comment-93532</link>
		<dc:creator>Anthony</dc:creator>
		<pubDate>Mon, 11 Oct 2010 05:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/42-global-variables/#comment-93532</guid>
		<description>What if I have a global variable, that gets edited in one function, but I need to check it in another function?</description>
		<content:encoded><![CDATA[<p>What if I have a global variable, that gets edited in one function, but I need to check it in another function?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

