<?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: 1.8 &#8212; Programs with multiple files</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 12:59:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bjb126</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-89273</link>
		<dc:creator>bjb126</dc:creator>
		<pubDate>Thu, 29 Jul 2010 23:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-89273</guid>
		<description>I tried compiling my main.cpp in Miscrosoft Visual Studio 2010 and I got this error.

1&gt;Test2.obj : error LNK2005: _main already defined in main.obj
1&gt;c:usersherminedocumentsvisual studio 2010ProjectsTest2DebugTest2.exe : fatal error LNK1169: one or more multiply defined symbols found</description>
		<content:encoded><![CDATA[<p>I tried compiling my main.cpp in Miscrosoft Visual Studio 2010 and I got this error.</p>
<p>1&gt;Test2.obj : error LNK2005: _main already defined in main.obj<br />
1&gt;c:usersherminedocumentsvisual studio 2010ProjectsTest2DebugTest2.exe : fatal error LNK1169: one or more multiply defined symbols found</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kraig</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-88944</link>
		<dc:creator>Kraig</dc:creator>
		<pubDate>Fri, 23 Jul 2010 02:09:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-88944</guid>
		<description>For Visual Studio users you need to have the code in add.cpp as follows

#include &quot;stdafx.h&quot;

#include 

int add(int x, int y)
{
    return x + y;
}</description>
		<content:encoded><![CDATA[<p>For Visual Studio users you need to have the code in add.cpp as follows</p>
<p>#include &#8220;stdafx.h&#8221;</p>
<p>#include </p>
<p>int add(int x, int y)<br />
{<br />
    return x + y;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: villain222</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-88212</link>
		<dc:creator>villain222</dc:creator>
		<pubDate>Sat, 10 Jul 2010 04:31:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-88212</guid>
		<description>ok.  i found my problem with code::blocks.  whatever your second file is, you just have to goto the left tree window and right click your file (not the main) pick properties goto build tab and make sure compile and Link boxes are checked as well as the debug and release.  once i did that I had no problems.  why it wasn&#039;t already set? not sure.</description>
		<content:encoded><![CDATA[<p>ok.  i found my problem with code::blocks.  whatever your second file is, you just have to goto the left tree window and right click your file (not the main) pick properties goto build tab and make sure compile and Link boxes are checked as well as the debug and release.  once i did that I had no problems.  why it wasn&#8217;t already set? not sure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mariusz</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-88033</link>
		<dc:creator>Mariusz</dc:creator>
		<pubDate>Wed, 07 Jul 2010 12:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-88033</guid>
		<description>Wait, is Code::Blocks an IDE, a kind of equivalent to Visual C++...? Then my problem is solved hehe.</description>
		<content:encoded><![CDATA[<p>Wait, is Code::Blocks an IDE, a kind of equivalent to Visual C++&#8230;? Then my problem is solved hehe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mariusz</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-88029</link>
		<dc:creator>Mariusz</dc:creator>
		<pubDate>Wed, 07 Jul 2010 10:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-88029</guid>
		<description>Hi,
I have a problem with Code::Blocks. I&#039;ve successfully followed all instructions in this chapter up to a point : &quot;In Code::Blocks, go to the file menu and choose “new file”...&quot; and so on. I have no clue on what to do at this point. I&#039;m using Visual C++ 2005 Express and can&#039;t even locate Code::Blocks. I&#039;m completely lost at this point.
Please, anyone help me.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I have a problem with Code::Blocks. I&#8217;ve successfully followed all instructions in this chapter up to a point : &#8220;In Code::Blocks, go to the file menu and choose “new file”&#8230;&#8221; and so on. I have no clue on what to do at this point. I&#8217;m using Visual C++ 2005 Express and can&#8217;t even locate Code::Blocks. I&#8217;m completely lost at this point.<br />
Please, anyone help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chip</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-85246</link>
		<dc:creator>Chip</dc:creator>
		<pubDate>Sun, 23 May 2010 15:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-85246</guid>
		<description>Hi.

I was trying to declare some struct types and enum types along with a few variables (of those types)in a separate file. In the header file I&#039;ve just included declaration of the variables with the extern keyword. (Yes, I&#039;m using global variables, but I&#039;m new to C++ and i couldn&#039;t figure out any other way. Besides it&#039;s not that big of a program to be that difficult to track down the variables.) But when the compiler gets to

#include &quot;buildings.h&quot; //the header file

it gives an error because it doesn&#039;t recognize the structs I&#039;ve declared in the separate file as types. If I declare the types in the main file before the line

#include &quot;buildings.h&quot;

it&#039;s all OK, but my idea was to keep the whole program somewhat clean so the types declarations and the variables of that types to be in the same separate file.

Is there something I could do to make the whole project easier to understand by keeping the variables and their custom made types (structs, enums)in one file and each function in a separate file, without having to crowd the main file code with type declarations?

P.S. Great lessons. Very comprehensible.</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>I was trying to declare some struct types and enum types along with a few variables (of those types)in a separate file. In the header file I&#8217;ve just included declaration of the variables with the extern keyword. (Yes, I&#8217;m using global variables, but I&#8217;m new to C++ and i couldn&#8217;t figure out any other way. Besides it&#8217;s not that big of a program to be that difficult to track down the variables.) But when the compiler gets to</p>
<p>#include &#8220;buildings.h&#8221; //the header file</p>
<p>it gives an error because it doesn&#8217;t recognize the structs I&#8217;ve declared in the separate file as types. If I declare the types in the main file before the line</p>
<p>#include &#8220;buildings.h&#8221;</p>
<p>it&#8217;s all OK, but my idea was to keep the whole program somewhat clean so the types declarations and the variables of that types to be in the same separate file.</p>
<p>Is there something I could do to make the whole project easier to understand by keeping the variables and their custom made types (structs, enums)in one file and each function in a separate file, without having to crowd the main file code with type declarations?</p>
<p>P.S. Great lessons. Very comprehensible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ziyad</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-84796</link>
		<dc:creator>ziyad</dc:creator>
		<pubDate>Mon, 17 May 2010 08:07:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-84796</guid>
		<description>file register system</description>
		<content:encoded><![CDATA[<p>file register system</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bram Verspeek</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-84461</link>
		<dc:creator>Bram Verspeek</dc:creator>
		<pubDate>Tue, 11 May 2010 20:35:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-84461</guid>
		<description>after int add(int x,inty) should be a ;
after int main() there shouldn&#039;t be a ;
I think the stdafx.h should be between &lt;pre&gt; &lt;stdafx.h&gt; &lt;/pre&gt;  instead of &quot; &quot;</description>
		<content:encoded><![CDATA[<p>after int add(int x,inty) should be a ;<br />
after int main() there shouldn&#8217;t be a ;<br />
I think the stdafx.h should be between
<pre> &lt;stdafx.h&gt; </pre>
<p>  instead of &#8221; &#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bram Verspeek</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-84456</link>
		<dc:creator>Bram Verspeek</dc:creator>
		<pubDate>Tue, 11 May 2010 16:19:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-84456</guid>
		<description>I have a question related to the multiple files programs.
Is it possible to define a value in the main program and use it in a function without supplying it as an argument?

Say in main.cpp I have

int a = 4

and then in math.cpp I have

&lt;pre&gt;//included so the program knows a should be an integer value
int a;

//function definitions
int add(int x,int y)
{
	cout &lt;&lt; &quot;a = &quot; &lt;&lt; a &lt;&lt;endl;
	return x+y;
}&lt;/pre&gt;

if i run code with this it prints a = 0 instead of a = 4. Is it possible to do this? basically declare global  variables that apply in every party of the program? I read a bit on so would a #define do what I want?</description>
		<content:encoded><![CDATA[<p>I have a question related to the multiple files programs.<br />
Is it possible to define a value in the main program and use it in a function without supplying it as an argument?</p>
<p>Say in main.cpp I have</p>
<p>int a = 4</p>
<p>and then in math.cpp I have</p>
<pre>//included so the program knows a should be an integer value
int a;

//function definitions
int add(int x,int y)
{
	cout &lt;&lt; &quot;a = &quot; &lt;&lt; a &lt;&lt;endl;
	return x+y;
}</pre>
<p>if i run code with this it prints a = 0 instead of a = 4. Is it possible to do this? basically declare global  variables that apply in every party of the program? I read a bit on so would a #define do what I want?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: armian</title>
		<link>http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/comment-page-1/#comment-84342</link>
		<dc:creator>armian</dc:creator>
		<pubDate>Sat, 08 May 2010 20:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=31#comment-84342</guid>
		<description>do i need to use include &#039;&#039;stdafx.h&#039;&#039;?</description>
		<content:encoded><![CDATA[<p>do i need to use include &#8216;&#8217;stdafx.h&#8221;?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
